aspose file tools
The moose likes Java in General and the fly likes roll doesn't work properly Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "roll doesn Watch "roll doesn New topic
Author

roll doesn't work properly

mike nu
Ranch Hand

Joined: Mar 11, 2001
Posts: 63
Hi there,
I ran into a problem with the roll method of GregorianCalendar class. Suppose the date is April 6, 00:00:00 2002, the following code will go throught the time changes:
GregorianCalendar cal = new GregorianCalender();
for (int i = 0; i < 24; i++) {
cal.roll(Calenader.HOUR_OF_DAY, 1);
}
April 6 01:00:00 2002
April 6 02:00:00 2002
.................
April 6 22:00:00 2002
April 6 23:00:00 2002
April 6 00:00:00 2002
But if the current date is April 7, 2002 (daylight saving time change will occur at 2:00 am this day), the above code will result:
April 7 01:00:00 2002
April 7 02:00:00 2002
.................
April 7 22:00:00 2002
April 7 23:00:00 2002
April 6 23:00:00 2002
April 6 00:00:00 2002
Can anyone tell me how to fix this problem or how to avoid this problem.
Thanks a lot.
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
There is a bug report open for this at: http://developer.java.sun.com/developer/bugParade/bugs/4312621.html
Their suggestion:
Use the add() method, instead of roll().


"JavaRanch, where the deer and the Certified play" - David O'Meara
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: roll doesn't work properly
 
Similar Threads
Calendar() / Date() bug ???
back ground process id ??
Gregorian roll() function- April Fools Bug??
current time problem on AIX
How to get Yesterday's date