-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
b46
-
x86
-
windows_xp
FULL PRODUCT VERSION :
see the out put of test code
ADDITIONAL OS VERSION INFORMATION :
windows2000, windows XP, linux32 bit, linux64 bit
A DESCRIPTION OF THE PROBLEM :
see the test code
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile the test code with JDK1.5 complier and run the class in corresponding JVM
after the code cal.set(Calendar.DAY_OF_MONTH, 1);
when call cal.getTime() will thorw IllegalArgumentException exception
but the code run well in JDK1.4.2
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the out put would be
week day of Month=Sun Nov 18 13:19:13 CST 2007
day of Month=Thu Nov 01 13:19:13 CST 2007
ACTUAL -
week day of Month=Sun Nov 18 14:15:31 CST 2007
Exception in thread "main" java.lang.IllegalArgumentException: WEEK_OF_MONTH
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2481)
at java.util.Calendar.updateTime(Calendar.java:2260)
at java.util.Calendar.getTimeInMillis(Calendar.java:1044)
at java.util.Calendar.getTime(Calendar.java:1017)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IllegalArgumentException: WEEK_OF_MONTH
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2481)
at java.util.Calendar.updateTime(Calendar.java:2260)
at java.util.Calendar.getTimeInMillis(Calendar.java:1044)
at java.util.Calendar.getTime(Calendar.java:1017)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class CalendarTest {
public CalendarTest() {
}
public static void main(String[] args) {
System.out.println("java.version=" + System.getProperty("java.version"));
System.out.println("java.vendor=" + System.getProperty("java.vendor"));
Calendar cal = Calendar.getInstance();
cal.setLenient("true".equalsIgnoreCase(args[0]));
cal.set(Calendar.YEAR, 2007);
cal.set(Calendar.MONTH, 10);
cal.set(Calendar.WEEK_OF_MONTH, 4);
cal.set(Calendar.DAY_OF_WEEK, 1);
System.out.println("week day of Month=" + cal.getTime());
cal.set(Calendar.DAY_OF_MONTH, 1);
System.out.println("day of Month=" + cal.getTime());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
replace cal.set(Calendar.DAY_OF_MONTH, 1);
with cal.add(Calendar.DATE, 1-cal.get(Calendar.DATE));
will bypass the bug.
see the out put of test code
ADDITIONAL OS VERSION INFORMATION :
windows2000, windows XP, linux32 bit, linux64 bit
A DESCRIPTION OF THE PROBLEM :
see the test code
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
compile the test code with JDK1.5 complier and run the class in corresponding JVM
after the code cal.set(Calendar.DAY_OF_MONTH, 1);
when call cal.getTime() will thorw IllegalArgumentException exception
but the code run well in JDK1.4.2
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
the out put would be
week day of Month=Sun Nov 18 13:19:13 CST 2007
day of Month=Thu Nov 01 13:19:13 CST 2007
ACTUAL -
week day of Month=Sun Nov 18 14:15:31 CST 2007
Exception in thread "main" java.lang.IllegalArgumentException: WEEK_OF_MONTH
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2481)
at java.util.Calendar.updateTime(Calendar.java:2260)
at java.util.Calendar.getTimeInMillis(Calendar.java:1044)
at java.util.Calendar.getTime(Calendar.java:1017)
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.lang.IllegalArgumentException: WEEK_OF_MONTH
at java.util.GregorianCalendar.computeTime(GregorianCalendar.java:2481)
at java.util.Calendar.updateTime(Calendar.java:2260)
at java.util.Calendar.getTimeInMillis(Calendar.java:1044)
at java.util.Calendar.getTime(Calendar.java:1017)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class CalendarTest {
public CalendarTest() {
}
public static void main(String[] args) {
System.out.println("java.version=" + System.getProperty("java.version"));
System.out.println("java.vendor=" + System.getProperty("java.vendor"));
Calendar cal = Calendar.getInstance();
cal.setLenient("true".equalsIgnoreCase(args[0]));
cal.set(Calendar.YEAR, 2007);
cal.set(Calendar.MONTH, 10);
cal.set(Calendar.WEEK_OF_MONTH, 4);
cal.set(Calendar.DAY_OF_WEEK, 1);
System.out.println("week day of Month=" + cal.getTime());
cal.set(Calendar.DAY_OF_MONTH, 1);
System.out.println("day of Month=" + cal.getTime());
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
replace cal.set(Calendar.DAY_OF_MONTH, 1);
with cal.add(Calendar.DATE, 1-cal.get(Calendar.DATE));
will bypass the bug.