JDK-6231602 : java.lang.IllegalArgumentException: HOUR_OF_DAY with 1.5, works with 1.4.2
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 1.4.2,5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,windows_2000,windows_xp
  • CPU: x86
  • Submitted: 2005-02-22
  • Updated: 2011-02-16
  • Resolved: 2005-03-28
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u6Fixed 6 b30Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
FULL PRODUCT VERSION :
E:\workspace\oXygen>java -version
java version "1.5.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java HotSpot(TM) Client VM (build 1.5.0-b64, mixed mode, sharing)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]

A DESCRIPTION OF THE PROBLEM :
The problem appeared first in Jing, with Java 1.5 it does not validate date values anymore. Tracing it down it appear to be caused by an java.lang.IllegalArgumentException thrown at at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2431).

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the class entered in the "Source code for an executable test case" entry.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The calendar time, for instance:
Tue Feb 03 02:00:00 EET 2004
ACTUAL -
Exception in thread "main" java.lang.IllegalArgumentException: HOUR_OF_DAY
	at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2431)
	at java.util.Calendar.updateTime(Calendar.java:2260)
	at java.util.Calendar.getTimeInMillis(Calendar.java:1044)
	at java.util.Calendar.getTime(Calendar.java:1017)
	at GregorianCalendarProblem.main(GregorianCalendarProblem.java:72)


ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IllegalArgumentException: HOUR_OF_DAY
	at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2431)
	at java.util.Calendar.updateTime(Calendar.java:2260)
	at java.util.Calendar.getTimeInMillis(Calendar.java:1044)
	at java.util.Calendar.getTime(Calendar.java:1017)
	at GregorianCalendarProblem.main(GregorianCalendarProblem.java:72)

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

/**
 * @author george
 */
public class GregorianCalendarProblem {
  public static void main(String[] args) {
    GregorianCalendar cal = new GregorianCalendar();
    cal.setLenient(false);
    cal.setGregorianChange(new Date(Long.MIN_VALUE));
    cal.clear();
    cal.set(Calendar.ZONE_OFFSET, 0);
    cal.set(Calendar.DST_OFFSET, 0);
    cal.set(Calendar.ERA, GregorianCalendar.AD);
    cal.set(2004, 1, 3, 0, 0, 0);
    cal.set(Calendar.MILLISECOND, 0);
    System.out.println(cal.getTime());
  }
}
---------- END SOURCE ----------
###@###.### 2005-2-22 12:13:45 GMT

Comments
EVALUATION Even when ZONE_OFFSET and/or DST_OFFSET are set, the calendar fields calculation uses time zone's offsets, which produces inconsistent time values. ###@###.### 2005-2-23 06:08:28 GMT
23-02-2005