Name: jl125535 Date: 02/05/2003
FULL PRODUCT VERSION :
java version "1.4.1_01"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1_01-b01)
Java HotSpot(TM) Client VM (build 1.4.1_01-b01, mixed mode)
FULL OPERATING SYSTEM VERSION :
Linux 2.4.9-21enterprise
ADDITIONAL OPERATING SYSTEMS :
Windows 2k
ALL because it is a problem in Calendar.java and its
subclasses
A DESCRIPTION OF THE PROBLEM :
Calling of the set method in Calendar causes the calendar to
shift from PDT back to PST. See test in Source Code
section.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the sample code in source code section.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected results:
date Sun Oct 27 01:00:00 PST 2002
date Sun Oct 27 01:59:59 PDT 2002
date Sun Oct 27 01:59:59 PDT 2002
Actual Results:
date Sun Oct 27 01:00:00 PST 2002
date Sun Oct 27 01:59:59 PDT 2002
date Sun Oct 27 01:00:59 PST 2002
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.*;
import java.math.*;
import java.net.*;
import java.text.*;
import java.util.*;
public class CalendarBug {
public static void main(String args[]){
long DELTA = 1111l;
Calendar cal = Calendar.getInstance();
cal.set(2002, Calendar.OCTOBER, 27, 1, 0, 0);
Date date = cal.getTime();
System.out.println("date " + date);
long delta = date.getTime() - DELTA;
cal.setTimeInMillis(delta);
date = cal.getTime();
System.out.println("date " + date);
// Anyone of the following set() or clear() calls will cause
// the date to switch from PDT to PST
cal.set( Calendar.MINUTE, 0 );
// cal.set( Calendar.SECOND, 0 );
// cal.set( Calendar.MILLISECOND, 0 );
// cal.clear( Calendar.MINUTE );
// cal.clear( Calendar.SECOND );
// cal.clear( Calendar.MILLISECOND );
date = cal.getTime();
System.out.println("date " + date);
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Use a set of something like
cal.set(Calendar.MINUTE, -1 * cal.get(Calendar.MINUTE));
(Review ID: 166646)
======================================================================