-
Bug
-
Resolution: Fixed
-
P4
-
5.0, 6u4
-
b08
-
generic, x86
-
generic, windows_xp
-
Verified
FULL PRODUCT VERSION :
Java<TM> 2 Runtime Environment, Standard Edition <build 1.5.0_08-b03>
Java HotSpot<TM> Client VM <build 1.5.0_08-b03, mixed mode, sharing>
ADDITIONAL OS VERSION INFORMATION :
Microsoft Window XP [ version 5.1.2600 ]
A DESCRIPTION OF THE PROBLEM :
The code is be below:
public class test {
public static void main(String[] args){
try{
GregorianCalendar gc1=new GregorianCalendar(1,0,1,0,0,0);
gc1.set(Calendar.HOUR,13865672);
System.out.println(gc1.getTime());
GregorianCalendar gc2=new GregorianCalendar(1,0,1,0,0,0);
gc2.set(Calendar.HOUR,13865696);
System.out.println(gc2.getTime());
}catch(Exception ex){ ex.printStackTrace();}
}
}
The output of the above code is:
Thu Oct 04 08:00:00 CST 1582
Sun Oct 17 08:00:00 CST 1582
Press any key to continue...
We can see that:
13865696-13865672=24
Only one day. But first line output 04while the second line output 17.
Strange!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class test {
public static void main(String[] args){
try{
GregorianCalendar gc1=new GregorianCalendar(1,0,1,0,0,0);
gc1.set(Calendar.HOUR,13865672);
System.out.println(gc1.getTime());
GregorianCalendar gc2=new GregorianCalendar(1,0,1,0,0,0);
gc2.set(Calendar.HOUR,13865696);
System.out.println(gc2.getTime());
}catch(Exception ex){ ex.printStackTrace();}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Thu Oct 04 08:00:00 CST 1582
Fri Oct 05 08:00:00 CST 1582
Press any key to continue...
ACTUAL -
Thu Oct 04 08:00:00 CST 1582
Sun Oct 17 08:00:00 CST 1582
Press any key to continue...
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class test {
public static void main(String[] args){
try{
GregorianCalendar gc1=new GregorianCalendar(1,0,1,0,0,0);
gc1.set(Calendar.HOUR,13865672);
System.out.println(gc1.getTime());
GregorianCalendar gc2=new GregorianCalendar(1,0,1,0,0,0);
gc2.set(Calendar.HOUR,13865696);
System.out.println(gc2.getTime());
}catch(Exception ex){ ex.printStackTrace();}
}
}
---------- END SOURCE ----------
Java<TM> 2 Runtime Environment, Standard Edition <build 1.5.0_08-b03>
Java HotSpot<TM> Client VM <build 1.5.0_08-b03, mixed mode, sharing>
ADDITIONAL OS VERSION INFORMATION :
Microsoft Window XP [ version 5.1.2600 ]
A DESCRIPTION OF THE PROBLEM :
The code is be below:
public class test {
public static void main(String[] args){
try{
GregorianCalendar gc1=new GregorianCalendar(1,0,1,0,0,0);
gc1.set(Calendar.HOUR,13865672);
System.out.println(gc1.getTime());
GregorianCalendar gc2=new GregorianCalendar(1,0,1,0,0,0);
gc2.set(Calendar.HOUR,13865696);
System.out.println(gc2.getTime());
}catch(Exception ex){ ex.printStackTrace();}
}
}
The output of the above code is:
Thu Oct 04 08:00:00 CST 1582
Sun Oct 17 08:00:00 CST 1582
Press any key to continue...
We can see that:
13865696-13865672=24
Only one day. But first line output 04while the second line output 17.
Strange!
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
public class test {
public static void main(String[] args){
try{
GregorianCalendar gc1=new GregorianCalendar(1,0,1,0,0,0);
gc1.set(Calendar.HOUR,13865672);
System.out.println(gc1.getTime());
GregorianCalendar gc2=new GregorianCalendar(1,0,1,0,0,0);
gc2.set(Calendar.HOUR,13865696);
System.out.println(gc2.getTime());
}catch(Exception ex){ ex.printStackTrace();}
}
}
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Thu Oct 04 08:00:00 CST 1582
Fri Oct 05 08:00:00 CST 1582
Press any key to continue...
ACTUAL -
Thu Oct 04 08:00:00 CST 1582
Sun Oct 17 08:00:00 CST 1582
Press any key to continue...
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class test {
public static void main(String[] args){
try{
GregorianCalendar gc1=new GregorianCalendar(1,0,1,0,0,0);
gc1.set(Calendar.HOUR,13865672);
System.out.println(gc1.getTime());
GregorianCalendar gc2=new GregorianCalendar(1,0,1,0,0,0);
gc2.set(Calendar.HOUR,13865696);
System.out.println(gc2.getTime());
}catch(Exception ex){ ex.printStackTrace();}
}
}
---------- END SOURCE ----------
- relates to
-
JDK-6549953 (cal) WEEK_OF_YEAR and DAY_OF_YEAR calculation problems around Gregorian cutover
- Closed
-
JDK-7109480 (cal) GregorianCalendar sets date to different values on JRE1.6 and JRE1.7
- Closed