Urgent Please
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, February 19, 2002 07:45 PM

Hi,

I am new to java.
Can any one send the code of calculating the the number of days betw two given dates.

Thank you.

Re: Urgent Please

Posted By:   Chandra_Patni  
Posted On:   Tuesday, February 19, 2002 10:57 PM

You can directly substract two millis of date and figure out the number of days. For example,

Date date1 = ....
Date date2 = .....
long diff = date1.getTime() - date2.getTime();
int year = (diff + 86400 * 500) / 86400/ 1000;

Note that I have added 12 hours for rounding.
About | Sitemap | Contact