Name: bb33257 Date: 02/23/98
Calendar.add(Calendar.HOUR, 1) doesn't work at DST onset.
The problem is that the time is incremented, but GregorianCalendar
is too clever and tries to adjust the time back for the DST shift.
The same problem will occur at the DST cessation and also with
other units of adding.
void test() {
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("PST"));
cal.setTime(new Date(98, Calendar.APRIL, 5, 1, 0));
Date before = cal.getTime();
cal.add(Calendar.HOUR, 1);
Date after = cal.getTime();
if (before.equals(after)) throw new Exception("FAIL");
}
======================================================================
- relates to
-
JDK-4350401 unix: Calendar.roll is broken on PST timezone
- Closed
-
JDK-4332659 regression test java/util/Calendar/CalendarRegression Test4114578 depends on PST
- Closed