Bug in Calendar when setting time across daylight-saving boundaries?!
Martin Egholm Nielsen
martin@egholm-nielsen.dk
Sat Oct 2 08:46:00 GMT 2004
Hi there,
I was just about to tear my hear out, when I suddenly discovered that
gcj's Calendar had some problems returning a correct Date-instance
[getTime()] when you have changed the date of a Calendar-instance across
the boundary of daylight-savings.
I little complicated in short terms, but consider todays date where I
live - it's October the 2nd. Hence, we are using daylight-savings. If I
then fetch a Calendar instance and change the month to November, the
same day of month, and the same hour of day, I have passed the date of
daylight savings, but then it goes wrong.
The calendar instance representing the future date calculates the
Date-instance wrong if I invoke #getTime(). The hour of day is an hour
short, but the day of month has suddenly gained a day - weird. Consider
the following output from an example-application compiled with gcj
illustrating the bug:
======== OUTPUT FROM GCJ ========
Calendar's date before: Sat Oct 02 10:30:52 GMT+02:00 2004
Calendar's date after: Wed Nov 03 09:30:52 GMT+01:00 2004
Calendar reports hour-of-day before: 10
Calendar reports hour-of-day after: 10
Calendar's date reports hour-of-day before: 10
Calendar's date reports hour-of-day after: 9
Calendar reports day-of-month before: 2
Calendar reports day-of-month after: 2
Calendar's date reports day-of-month before: 2
Calendar's date reports day-of-month after: 3
Sun's Java returns the expected:
======== OUTPUT FROM SUN ========
Calendar's date before: Sat Oct 02 10:11:28 GMT+02:00 2004
Calendar's date after: Tue Nov 02 10:11:28 GMT+01:00 2004
Calendar reports hour-of-day before: 10
Calendar reports hour-of-day after: 10
Calendar's date reports hour-of-day before: 10
Calendar's date reports hour-of-day after: 10
Calendar reports day-of-month before: 2
Calendar reports day-of-month after: 2
Calendar's date reports day-of-month before: 2
Calendar's date reports day-of-month after: 2
I have attached the example application.
Does anybody know if this bug has been corrected in recent libgcj's?
I've seen it with both gcj 3.3.3 and 3.4.0.
Best regards,
Martin Egholm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CalendarTest.java
Type: text/x-java
Size: 2582 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/java/attachments/20041002/b2ad84fc/attachment.bin>
More information about the Java
mailing list