The Hour class does not work correctly when the daylight savings time ends;
one hour is duplicated.
Using the java.util.Calendar class and the Hour(Date, TimeZone) constructor
followed by a call to getFirstMillisecond(Calendar), the following error
occurs (the two millisecond value on each row should be equal):
28.10.07 00:00 Hour: 00 Calendar ms: 119352240 Hour (ms): 119352240
DST:true
28.10.07 01:00 Hour: 01 Calendar ms: 119352600 Hour (ms): 119352600
DST:true
28.10.07 02:00 Hour: 02 Calendar ms: 119352960 Hour (ms): 119353320
DST:false
The reason is that constructing a point in time using <year, month, day,
hour, minute, second, ms> is ambiguous, see the implementation of
Hour.getFirstMillisecond(Calendar calendar). When daylight savings ends,
there will be two hours with the same combination of values, but they do
differ in values of Calendar.getTimeInMillis(). The Calendar class has no
way of knowing which of the two points in time the caller intends, and
picks one of them.
A good way to solve this problem is to always store the millisecond value
("the current time as UTC milliseconds from the epoch" as stated in the
Java API doc).
Nobody/Anonymous
None
None
Public
| Filename | Description | Download |
|---|---|---|
| PowelHour.java | Workaround by extending Hour | Download |
| Field | Old Value | Date | By |
|---|---|---|---|
| File Added | 266445: PowelHour.java | 2008-02-15 12:16 | fbertilsson |
Copyright © 2010 Geeknet, Inc. All rights reserved. Terms of Use