01.
import java.util.Calendar;02.
03.
public class DaysBWDates {04.
public static void main (String[] args) {05.
Calendar cal1 = Calendar.getInstance();06.
Calendar cal2 = Calendar.getInstance();07.
cal2.add(Calendar.DATE, -3);08.
09.
long noOfDays = (cal1.getTimeInMillis()10.
11.
System.out.println("Date1: " + cal1.getTime());12.
System.out.println("Date2: " + cal2.getTime());13.
System.out.println ("No of days between two dates: " + noOfDays);14.
}15.
}
Wednesday, July 6, 2011
Find no of days between two dates in java
Labels:
Java