Difference Between Dates With Daylight Savings Time in Java

An interesting post about date math. Computing the difference between dates seems like a simple problem. Get an instance at the same time for the two dates. Subtract the time in millis, and divide by millis in a day.This works fine until DST rears it’s ugly head.

Here’s a post with an easy to understand, but not particularly efficient method, and a second more efficient method.

Later in the comments, one poster also suggests enforcing a TimeZone of GMT on the calendar, and this also appears to work.

http://tripoverit.blogspot.com/2007/07/…

It's only fair to share...
Share on Facebook
Facebook
Google+
Google+
Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Leave a Reply