Duplicate :
|
|
Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
FULL PRODUCT VERSION : 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
|