Forums Register Login

Help reg. Days & Dates...

+Pie Number of slices to send: Send
Hey e'body,...
It would be Great if anybody can help me with, how I can find the number of Days between two dates..
like for example # days between 08/07/2003 & 09/15/2003 ..
Which Class do you suggest me to Use.. ( Date,Calendar,DateFormat ??? how?)
Thx a lot for your help.. Appreciate it..
+Pie Number of slices to send: Send
The way I usually do something like that is...
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
Date d1 = dateFormat.parse("08/07/2003");
Date d2 = dateFormat.parse("09/15/2003");
long time = d2.getTime() - d1.getTime(); // t dif in ms
// then convert time to the time units you want
+Pie Number of slices to send: Send
Thanks a lot Chris..
So If you want me to get the # of days ...
I think i'll Go this way :
long time = d2.getTime() - d1.getTime(); // t dif in ms
int days=(int)time/(24*36*100000);
I hope this is going to work always..
Let me know, if by chance i'm going wrong somewhere..
Thx anyway
You can't have everything. Where would you put it?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1286 times.
Similar Threads
Calculating no. of working days between tow dates
Subtracting Dates in JAVA
How to get the difference between 2 dates ?
days between dates
Extracting months from Date object data
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 12:45:26.