Name: bsC130419 Date: 05/16/2001
$ java -version
java version "1.3.0_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0_02)
Java HotSpot(TM) Client VM (build 1.3.0_02, mixed mode)
Calling Calendar.add for sub-hour fields, during the first occurence of the
doubled time during a daylight-savings-time transition, yields the incorrect
resulting time, if the time fields are recalculated.
Sample source code:
import java.util.*;
import java.text.*;
public class TestDST {
public static void main(String[] argv) {
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL,
DateFormat.FULL);
df.setTimeZone(TimeZone.getTimeZone("America/New_York"));
Calendar now =
new GregorianCalendar(TimeZone.getTimeZone("America/New_York"));
now.setTime(new Date(877843800000L));
// Sunday, October 26, 1997 1:30:00 AM EDT
System.out.println(df.format(now.getTime()));
System.out.println(now.getTime().getTime());
now.clear(Calendar.WEEK_OF_YEAR); // force fields to be cleared
now.add(Calendar.SECOND, -1);
System.out.println(df.format(now.getTime()));
System.out.println(now.getTime().getTime());
}
}
Observed output:
$ java TestDST
Sunday, October 26, 1997 1:30:00 AM EDT
877843800000
Sunday, October 26, 1997 1:29:59 AM EST
877847399000
Expected output:
Sunday, October 26, 1997 1:30:00 AM EDT
877843800000
Sunday, October 26, 1997 1:29:59 AM EDT
877843799000
(Review ID: 124505)
======================================================================