-
Bug
-
Resolution: Fixed
-
P3
-
5.0
-
1.3
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2116332 | 5.0 | Jeff Suttor | P3 | Resolved | Fixed | b55 |
Name: erR10175 Date: 05/19/2004
Two following methods of the class javax.xml.datatype.DatatypeFactory
public XMLGregorianCalendar newXMLGregorianCalendar(int year, int month, int day, int hour,
int minute, int second, int millisecond, int timezone)
public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours, int minutes, int seconds,
int milliseconds, int timezone)
throw IllegalArgumentException if the milliseconds parameter is greater than 1.
The javadoc of the class javax.xml.datatype.XMLGregorianCalendar specifies the millisecond
field as the convenience millisecond precision of value of getFractionalSecond() so that
the following equation is satisfied:
getMillisecond()/1000 == getFractionalSecond()
As the FractionalSecond is in range from 0.0 to 1.0, the millisecond may vary from 0 to
1000, and thus the value '2' should be accepted but the RI throws IllegalArgumentException
(see the test below).
This bug affects new tests in JCK 1.5
api/javax_xml/datatype/DatatypeFactory/index.html#NewXMLGregorianCalendar[NewXMLGregorianCalendar005]
api/javax_xml/datatype/DatatypeFactory/index.html#NewXMLGregorianCalendar[NewXMLGregorianCalendarTime005]
The bug is found in jdk1.5.0/beta/b51.
To reproduce the bug compile and run test.java as shown in the log below:
------------------------------------------ test.java
import javax.xml.datatype.DatatypeFactory;
class test {
public static void main(String [] args) throws Exception {
DatatypeFactory df = DatatypeFactory.newInstance();
df.newXMLGregorianCalendar(9999, 12, 31, 23, 59, 59, 0, 840);
System.out.println("Passed. 0");
df.newXMLGregorianCalendar(9999, 12, 31, 23, 59, 59, 1, 840);
System.out.println("Passed. 1");
df.newXMLGregorianCalendar(9999, 12, 31, 23, 59, 59, 2, 840);
System.out.println("Passed. 2");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode)
Passed. 0
Passed. 1
Exception in thread "main" java.lang.IllegalArgumentException: invalid value 2 for fractional second
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.setFractionalSecond(XMLGregorianCalendarImpl.java:2672)
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.setTime(XMLGregorianCalendarImpl.java:1316)
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.<init>(XMLGregorianCalendarImpl.java:484)
at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(DatatypeFactoryImpl.java:326)
at javax.xml.datatype.DatatypeFactory.newXMLGregorianCalendar(DatatypeFactory.java:733)
at test.main(test.java:11)
----------------------------------------------------
======================================================================
Two following methods of the class javax.xml.datatype.DatatypeFactory
public XMLGregorianCalendar newXMLGregorianCalendar(int year, int month, int day, int hour,
int minute, int second, int millisecond, int timezone)
public XMLGregorianCalendar newXMLGregorianCalendarTime(int hours, int minutes, int seconds,
int milliseconds, int timezone)
throw IllegalArgumentException if the milliseconds parameter is greater than 1.
The javadoc of the class javax.xml.datatype.XMLGregorianCalendar specifies the millisecond
field as the convenience millisecond precision of value of getFractionalSecond() so that
the following equation is satisfied:
getMillisecond()/1000 == getFractionalSecond()
As the FractionalSecond is in range from 0.0 to 1.0, the millisecond may vary from 0 to
1000, and thus the value '2' should be accepted but the RI throws IllegalArgumentException
(see the test below).
This bug affects new tests in JCK 1.5
api/javax_xml/datatype/DatatypeFactory/index.html#NewXMLGregorianCalendar[NewXMLGregorianCalendar005]
api/javax_xml/datatype/DatatypeFactory/index.html#NewXMLGregorianCalendar[NewXMLGregorianCalendarTime005]
The bug is found in jdk1.5.0/beta/b51.
To reproduce the bug compile and run test.java as shown in the log below:
------------------------------------------ test.java
import javax.xml.datatype.DatatypeFactory;
class test {
public static void main(String [] args) throws Exception {
DatatypeFactory df = DatatypeFactory.newInstance();
df.newXMLGregorianCalendar(9999, 12, 31, 23, 59, 59, 0, 840);
System.out.println("Passed. 0");
df.newXMLGregorianCalendar(9999, 12, 31, 23, 59, 59, 1, 840);
System.out.println("Passed. 1");
df.newXMLGregorianCalendar(9999, 12, 31, 23, 59, 59, 2, 840);
System.out.println("Passed. 2");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java && java -cp . -showversion test
java version "1.5.0-beta2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode)
Passed. 0
Passed. 1
Exception in thread "main" java.lang.IllegalArgumentException: invalid value 2 for fractional second
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.setFractionalSecond(XMLGregorianCalendarImpl.java:2672)
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.setTime(XMLGregorianCalendarImpl.java:1316)
at com.sun.org.apache.xerces.internal.jaxp.datatype.XMLGregorianCalendarImpl.<init>(XMLGregorianCalendarImpl.java:484)
at com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(DatatypeFactoryImpl.java:326)
at javax.xml.datatype.DatatypeFactory.newXMLGregorianCalendar(DatatypeFactory.java:733)
at test.main(test.java:11)
----------------------------------------------------
======================================================================
- backported by
-
JDK-2116332 DatatypeFactory.newXMLGregorianCalendar(..) does not accept milliseconds
- Resolved
-
JDK-2116333 DatatypeFactory.newXMLGregorianCalendar(..) does not accept milliseconds
- Closed