-
Bug
-
Resolution: Fixed
-
P3
-
5.0, 5.0u5
-
b53
-
x86, sparc
-
linux, solaris_10, windows_xp
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2131103 | 5.0u7 | Yuka Kamiya | P3 | Resolved | Fixed | b01 |
java version "1.5.0-rc"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-rc-b63)
Java HotSpot(TM) Client VM (build 1.5.0-rc-b63, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
Setting the 'HOUR' field of a freshly created GregorianCalendar has no effect on the Date value returned by a subsequent call to getTime().
You have to call getTime() at least once before setting the 'HOUR' field to make it work.
There is no problem with setting the 'HOUR_OF_DAY' field
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Compile and run the test code under jdk 1.5 , watch the output to stdout.
It does work in prior releases of the VM (at least up to 1.4.2_04)
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Date: Thu Jan 01 01:00:00 CET 2004
ACTUAL -
Date: Thu Jan 01 00:00:00 CET 2004
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.util.*;
public class CalTest {
public CalTest() {}
public static void main(String[] args) {
GregorianCalendar cal = new GregorianCalendar(2004, 0,1);
// activating this line makes it work!
// cal.getTime();
cal.set(Calendar.HOUR, 1);
System.out.println("Date: " + cal.getTime());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Call getTime() in advance or use HOUR_OF_DAY instead.
Release Regression From : 1.4.2
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
###@###.### 10/12/04 21:56 GMT
- backported by
-
JDK-2131103 (cal) REGRESSION: GregorianCalendar.set(Calendar.HOUR, ...) has no effect
-
- Resolved
-
- duplicates
-
JDK-6328057 REGRESSION: getTime() returns wrong time in 1.5.0, worked fine in 1.4.2
-
- Closed
-
-
JDK-6358451 (cal) GregorianCalendar fails to set HOUR after clone
-
- Closed
-
-
JDK-6609357 (cal) HOUR and HOUR_OF_DAY fields of Calender Object are not syncronized in Java 1.5
-
- Closed
-
- relates to
-
JDK-6440854 (cal) Exception for Gregorian Calendar class created with 3 parameter constructor
-
- Resolved
-
-
JDK-4846659 Calendar: Both set() and roll() don't work for AM_PM time field
-
- Closed
-