I've been using GregorianCalendar to compute time difference between two dates. The package works well most of the time except at one mysterious time interval : March 8 around 2 and 3 am. The computation of elapsed time is always off in this interval.
Time 1 : 2009-03-08 03:07:44
Time 2 : 2009-03-08 02:27:30
Elapsed time for Time 1 : 343474.12888888887
Elapsed time for Time 2 : 343474.4583333333
Time 2 is earlier than Time 1, yet its elapsed time is longer. The code I use to generate the time is simply
double time = new GregorianCalendar(year, month, day, hour, minute, second).getTime().getTime();
I have a lot more examples in this interval. Does anybody know what's going on? Am I the only one seeing this? What am I missing? Thanks!!
For your best chances of getting help, you may wish to create and post a small but complete compilable, runnable program that demonstrates your problem, in sum, an SSCCE.
Also for what it's worth, any time I've been absolutely, completely, and 100% sure that there's a bug in Java, I've been wrong, and the error has been mine. I guess the folks who created Java are smarter and less prone to creating errors than I am. Perhaps your luck will be better. :)
You might want to include locale/timezone stuff if that makes the SSCCE repeatable. I note that 2:30 did not exist on that date in the CDT timezone.
Ever heard of DST?
What am I missing?