Results 1 to 4 of 4
Thread: GregorianCalendar bug?
- 11-11-2010, 12:13 AM #1
Member
- Join Date
- Nov 2010
- Posts
- 1
- Rep Power
- 0
GregorianCalendar bug?
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.
For example,
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. :)
- 11-11-2010, 02:19 AM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
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.
- 11-11-2010, 05:24 AM #4
Similar Threads
-
GregorianCalendar mishap
By kasur in forum New To JavaReplies: 9Last Post: 07-30-2010, 10:15 AM -
GregorianCalendar help
By Sturm in forum New To JavaReplies: 0Last Post: 02-03-2010, 09:43 PM -
Problem with "GregorianCalendar"
By tola.ch2004 in forum New To JavaReplies: 2Last Post: 07-12-2007, 08:12 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks