-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
1.3.0
-
x86
-
linux
Name: dkC103137 Date: 07/05/2000
Following test shows that Calendar.roll() method returns incorrect result if
timezone is set using TimeZone.getTimeZone("PST") for calendar object. Test
fails under Solaris JDK1.3 and Linux JDK1.3. Regression test
java/util/Calendar/CalendarRegression Test4114578 fails due to this bug.
Note that if timezone is set using TimeZone.getTimeZone("GMT - 08:00") then test
passes.
---------------------- Test.java -----------------------------
import java.util.*;
import java.text.*;
public class Test {
public static void main(String[] args) throws Exception {
int ONE_HOUR = 60*60*1000;
Calendar cal = Calendar.getInstance();
Date testDate = new Date(99, Calendar.OCTOBER, 25, 1, 0);
cal.setTimeZone(TimeZone.getTimeZone("PST"));
//cal.setTimeZone(TimeZone.getTimeZone("GMT - 08:00"));
cal.setTime(testDate);
System.out.println("Date before roll - " + cal.getTime().toString());
cal.roll(Calendar.HOUR, 1);
long change = cal.getTime().getTime() - testDate.getTime();
long expectedChange = ONE_HOUR;
if (change != expectedChange) {
System.out.println("Test failed!");
System.out.println("actual change - " + change);
System.out.println("expected change - " + expectedChange);
System.out.println("Date after roll 1 hour - " +
cal.getTime().toString());
}
}
}
------------------------- output -----------------------------
$ java -version
java version "1.3.0beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0beta-b09)
Java HotSpot(TM) Client VM (build 1.3.0beta-b07, mixed mode)
$ java Test
Date before roll - Mon Oct 25 01:00:00 GMT+07:00 1999
Test failed!
actual change - -39600000
expected change - 3600000
Date after roll 1 hour - Sun Oct 24 14:00:00 GMT+07:00 1999
$
------------------------------------------------------------------
======================================================================
- relates to
-
JDK-4114578 Calendar.add broken at DST onset
-
- Closed
-
-
JDK-4332659 regression test java/util/Calendar/CalendarRegression Test4114578 depends on PST
-
- Closed
-