× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



From: Don Yantzi

Improved in that it's 4 less lines of code :)

GregorianCalendar date1 = new GregorianCalendar(2008, 01, 15, 0, 0);
GregorianCalendar date2 = new GregorianCalendar(2008, 01, 21, 23, 59);

long diff = Math.abs(date2.getTimeInMillis() - date1.getTimeInMillis());
diff = diff / (1000 * 60 * 60 * 24);

System.out.println(diff);

And the concern here is that the same number of milliseconds might actually
represent different numbers of "days", depending on what you're trying to
determine.

For example, the number of seconds between 8AM on Tuesday and 8PM on
Wednesday is exactly the same as the number of seconds from 8PM on Wednesday
to 8AM on Friday. However, depending on how your scheduling algorithm
works, I could easily envision a situation where the former is treated as
one day, while the latter must be treated as two.

Joe


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.