Name: erR10175 Date: 12/26/2003
The following method of the class javax.xml.datatype.XMLGregorianCalendar
public boolean isValid()
allows year 0000 and does not account for leap days in FEBRUARY.
According to the javadoc of the method, it must validate instance by
appropriate XML Schema type constraints. XML Schema type 'date' prohibits
29th of FEBRUARY if the year is not leap. XML Schema 1.0 Specification Errata
prohibits the year 0000. So, the method must return false for both '1999-02-29'
and '0000-01-01'.
This bug affects new test in JCK 1.5 (not integrated yet)
api/javax_xml/datatype/XMLGregorianCalendar/index.html#IsValid[IsValid001]
The bug is found in jdk1.5.0/beta/b32.
To reproduce the bug compile and run the following code as shown
in the log below.
------------------------------------------ test.java
import javax.xml.datatype.XMLGregorianCalendar;
class test {
public static void main(String [] args) {
XMLGregorianCalendar c
= XMLGregorianCalendar.createDate(1999,2,29,0);
boolean valid = c.isValid();
if (valid) {
System.out.println("Failed: '1999-02-29'.isValid()"
+ " returns true, expected false");
} else {
System.out.println("OK: '1999-02-29'.isValid() returns false");
}
c = XMLGregorianCalendar.createDate(0,1,1,0);
valid = c.isValid();
if (valid) {
System.out.println("Failed: '0000-01-01'.isValid()"
+ " returns true, expected false");
} else {
System.out.println("OK: '0000-01-01'.isValid() returns false");
}
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)
Failed: '1999-02-29'.isValid() returns true, expected false
Failed: '0000-01-01'.isValid() returns true, expected false
----------------------------------------------------
======================================================================
The following method of the class javax.xml.datatype.XMLGregorianCalendar
public boolean isValid()
allows year 0000 and does not account for leap days in FEBRUARY.
According to the javadoc of the method, it must validate instance by
appropriate XML Schema type constraints. XML Schema type 'date' prohibits
29th of FEBRUARY if the year is not leap. XML Schema 1.0 Specification Errata
prohibits the year 0000. So, the method must return false for both '1999-02-29'
and '0000-01-01'.
This bug affects new test in JCK 1.5 (not integrated yet)
api/javax_xml/datatype/XMLGregorianCalendar/index.html#IsValid[IsValid001]
The bug is found in jdk1.5.0/beta/b32.
To reproduce the bug compile and run the following code as shown
in the log below.
------------------------------------------ test.java
import javax.xml.datatype.XMLGregorianCalendar;
class test {
public static void main(String [] args) {
XMLGregorianCalendar c
= XMLGregorianCalendar.createDate(1999,2,29,0);
boolean valid = c.isValid();
if (valid) {
System.out.println("Failed: '1999-02-29'.isValid()"
+ " returns true, expected false");
} else {
System.out.println("OK: '1999-02-29'.isValid() returns false");
}
c = XMLGregorianCalendar.createDate(0,1,1,0);
valid = c.isValid();
if (valid) {
System.out.println("Failed: '0000-01-01'.isValid()"
+ " returns true, expected false");
} else {
System.out.println("OK: '0000-01-01'.isValid() returns false");
}
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32)
Java HotSpot(TM) Client VM (build 1.5.0-beta-b32, mixed mode)
Failed: '1999-02-29'.isValid() returns true, expected false
Failed: '0000-01-01'.isValid() returns true, expected false
----------------------------------------------------
======================================================================