-
Bug
-
Resolution: Fixed
-
P2
-
1.4.0
-
mantis
-
x86
-
linux
Name: rmT116609 Date: 05/15/2002
FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)
FULL OPERATING SYSTEM VERSION :
Mandrake
Linux aurore.inrialpes.fr 2.4.18-6mdksmp #1 SMP Fri Mar 15
01:24:36 CET 2002 i686 unknown
glibc-2.2.4-25mdk
Microsoft Windows 2000
A DESCRIPTION OF THE PROBLEM :
JDK1.3 or JDK1.4 Documentation: When using Calendar.set() method the calendar's milliseconds is not recomputed until the next call to get(), getTime(), or getTimeInMillis() is made.
It works fine with JDK1.3 and prior, but with JDK1.4 nor the getTime() method, nor the getTimeInMillis() methods recomputes the calendar's.
REGRESSION. Last worked in version 1.3.1_03
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. compile the program: "javac calendar.java"
2. run it: "java calendar"
3. uncomment the 'calendar.get()' call.
4. compile the program: "javac calendar.java"
5. run it: "java calendar"
6. compare the two results. You can also obtain the "good" result with the original program and a JDK1.3 or prior.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expected result (as obtained with JDK prior to 1.4):
calendar = 31/12/99
calendar = 02/01/00
calendar = 02/01/00
calendar = 31/12/99
Actual result:
calendar = 31/12/99
calendar = 02/01/00
calendar = 02/01/00
calendar = 30/11/99
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
import java.text.DateFormat;
public class calendar {
public static void main(String args[]) throws Exception {
Calendar calendar = Calendar.getInstance();
DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT, Locale.FRANCE);
calendar.setTime(df.parse("31/12/1999"));
System.out.println("calendar = " + df.format(calendar.getTime()));
calendar.set(Calendar.DAY_OF_MONTH, 33);
System.out.println("calendar = " + df.format(calendar.getTime()));
calendar.getTime();
// calendar.get(Calendar.MONTH);
System.out.println("calendar = " + df.format(calendar.getTime()));
calendar.set(Calendar.DAY_OF_MONTH, 0);
System.out.println("calendar = " + df.format(calendar.getTime()));
}
}
---------- END SOURCE ----------
CUSTOMER WORKAROUND :
Use of Calendar.get() method for recompute calendar.
Release Regression From : 1.3.1_03
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
(Review ID: 146589)
======================================================================
- relates to
-
JDK-4851640 Calling get(...) / getTime() on a Calendar instance makes isSet(...) useless!
-
- Resolved
-
-
JDK-4727451 GregorianCalendar constructors set invalid setting state for ERA
-
- Resolved
-
-
JDK-4860664 REGRESSION:Calendar get(Calendar.DAY_OF_WEEK)invalid under certain circumstances
-
- Resolved
-