Menu
Question Index
...

Write a program to find the number of days between two given dates.

Input (Date, Date) Output(Integer)
2013-1-15 and 2013-1-01 14
2013-1-26 and 1947-8-15 23906
2010-11-28 and 2005-12-31 1792
2010-1-1 and 2020-1-1 3652
2001-1-1 and 2000-1-1 366


import java.util.*;
class NumberOfDaysBetweenTwoDates
{
    public static void main(String s[])
    {
        Calendar cal1 = new GregorianCalendar();
        Calendar cal2 = new GregorianCalendar();
        cal1.set(2013, 1, 15);
        cal2.set(2013, 1, 1);
        System.out.println("Number of Days : " + numberOfDays(cal1.getTime(), cal2.getTime()));

    }


    public static int numberOfDays(Date date1, Date date2) {
    int result = 0;
    return result;
    }

}

Doubts

Problems

Topic: Java GregorianCalendar

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App