6.9 Notes on the javax.xml.datatype Package

The following table gives cautionary notes on the javax.xml.datatype package.

Table 6-19 Notes on the javax.xml.datatype package

No.Notes
1In multi-thread programming, the objects defined by the javax.xml.datatype package are not thread-safe. Therefore, make sure that each thread exclusively accesses these objects.
2If the IllegalArgumentException occurs in each method of the DatatypeFactory class, the parameter specified for each method is returned to the getMessage() method.
3If you set the month field to either 4, 6, 9, or 11 in the newXMLGregorianCalendar, newXMLGregorianCalendarDate, and newXMLGregorianCalendarTime methods of the DatatypeFactory class, an error does not occur even when you set 31 in the day field.
4Specify the value from 0 to 999 for the millisecond argument of the newXMLGregorianCalendar and newXMLGregorianCalendarTime methods of the DatatypeFactory class.
5If you compare a Duration object whose month field has the value 1 and a Duration object whose day field has the value 28, the result is as follows:
  • If you compare by using the compare method, DatatypeConstants.EQUAL is returned.
  • If you compare by using the equals method, true is returned.
6The Duration object created in the newDuration(long durationInMilliSeconds), newDurationDayTime(long durationInMilliSeconds), or newDurationYearMonth(long durationInMilliSeconds) method of the DatatypeFactory class is the DatatypeConstants.DURATION_DAYTIME type. Therefore, the month field and day field of this Duration object are set to 0.
7Specify the value from 0 to 23 for the hour argument of the setHour and setTime methods of the XMLGregorianCalendar class. Also, specify a value from 0 to 23 for the time field of the argument of the newXMLGregorianCalendar and newXMLGregorianCalendarTime methods of the DatatypeFactory class.
8In the JAXP1.4 specifications, the specifications of the isValid method of the XMLGregorianCalendar class are defined as the Validate instance by getXMLSchemaType() constraints. In Cosminexus XML Processor, true is returned when all the following constraints are met:
  • If the month field is 2, the day field is 28 or smaller (other than leap year) or 29 or smaller (leap year).
  • The year field is not 0.
9If the argument of the equals method of the XMLGregorianCalendar class is null, a NullPointerException does not occur, but false is returned.
10The text expression obtained by applying the toString and toXMLFormat methods to the XMLGregorianCalendar object of the DatatypeConstants.GMONTH type is not the character string --MM defined in section 3.2.14 of the specification W3C XML Schema 1.0 Part 2 (second edition), but the string --MM-- defined in the specifications prior to the second edition.