|
Quick Lists
|
|
Bug ID:
|
4401223
|
|
Votes
|
3
|
|
Synopsis
|
Gregorian calendar gives a java.lang.IllegalArgumentException only on 12-31-00
|
|
Category
|
java:classes_util_i18n
|
|
Reported Against
|
1.3
, 1.2.2
, 1.3.1_09
, merlin-beta
|
|
Release Fixed
|
1.4(merlin-beta)
|
|
State
|
10-Fix Delivered,
Verified,
bug
|
|
Priority:
|
1-Very High
|
|
Related Bugs
|
4398844
,
4994273
|
|
Submit Date
|
02-JAN-2001
|
|
Description
|
Gregorian calendar gives a java.lang.IllegalArgumentException only on 12-31-00.
The exception arises even in jdk 1.3.0_01 and also jdk 1.2.2_06.
TEST CASE FROM CUSTOMER
=======================
import java.util.*;
public class GregCalBug {
protected GregorianCalendar gc;
public void run() {
int nYear;
gc = new GregorianCalendar();
gc.setLenient(false); /* Bug only manifest if lenient set false */
try
{
gc.set(2001, 1, 1, 1, 0, 0);
nYear = gc.get(Calendar.YEAR);
}
catch (Exception ex)
{
System.out.println("We should _not_ be here!");
System.out.println(ex);
}
}
public static void main(String[] args) {
System.out.println("This small Java class demonstrates a bug in");
System.out.println("Solaris JVM JDK 1.2.1_04");
GregCalBug me = new GregCalBug();
me.run();
}
}
Output of the above test case when date is set to 12-31-00.
smala:/home/mala2/gregorian 62 % java -fullversion
java full version "1.3.0_01"
smala:/home/mala2/gregorian 63 % javac GregCalBug.java
smala:/home/mala2/gregorian 64 % java GregCalBug
This small Java class demonstrates a bug in
Solaris JVM JDK 1.2.1_04
We should _not_ be here!
java.lang.IllegalArgumentException
smala:/home/mala2/gregorian 65 %
|
|
Work Around
|
Please call gc.clear() before gc.set() to clear the wrong value in time fields.
xxxxx@xxxxx 2001-01-09
|
|
Evaluation
|
This bug is reproducible on December 31 in any leap year. (But not reproducible on 2001.12.31.)
xxxxx@xxxxx 2001-01-09
Corrected the condition of checking the fields(DATE and DAY_OF_YEAR) validity.
xxxxx@xxxxx 2001-01-15
This bug was fixed in 1.4 (beta) and 1.3.1_12.
xxxxx@xxxxx 2004-12-24 02:02:11 GMT
|
|
Comments
|
Submitted On 22-AUG-2003
Jonny_De_Hertogh
doesn't occur in jdk1.3.1_06 while the related bug 4398844
still occurs
used testcode:
Calendar cal = new GregorianCalendar();
cal.setLenient(false);
cal.set(1952, 11, 31, 0, 0, 0);
Assert.assertEquals(31, cal.get(Calendar.DAY_OF_MONTH));
Assert.assertEquals(11, cal.get(Calendar.MONTH));
Assert.assertEquals(1952, cal.get(Calendar.YEAR));
-> all the asserts returns true
Submitted On 03-NOV-2005
This bug is also seen in jdk1.3.1_08
Here's what I did:
Calendar cal = Calendar.getInstance();
cal.clear();
cal.set(1992, 12, 31);
cal.add(Calendar.YEAR,4);
I get an IllegalArgumentException at this point.
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |