Re: method to find difference between dates
Posted By:
Ravi_Verelly
Posted On:
Tuesday, September 4, 2001 12:54 PM
The following is one solution, as there are numerous ways we can achieve this:
import java.util.*;
int syear = 2000;
int eyear = 2000;
int smonth = 2;//Feb
int emonth = 3;//Mar
int sday = 27;
int eday = 1;
Date startDate = new Date(syear-1900,smonth-1,sday);
Date endDate = new Date(eyear-1900,emonth-1,eday);
int difInDays = (int) ((endDate.getTime() - startDate.getTime())/(1000*60*60*24));
Re: method to find difference between dates
Posted By:
AlessandroA_Garbagnati
Posted On:
Tuesday, September 4, 2001 07:52 AM
Hi,
There is no such method, but you can easily write the code using, for example, the class java.util.Calendar.