Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6715402

DatatypeFactory.newXMLGregorianCalendar mishandles T24:00:00

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6
    • xml
    • x86
    • windows_vista

      FULL PRODUCT VERSION :
      java version "1.6.0_05"
      Java(TM) SE Runtime Environment (build 1.6.0_05-b13)
      Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows Vista SP1

      A DESCRIPTION OF THE PROBLEM :
      DatatypeFactory.newXMLGregorianCalendar mishandles T24:00:00

      The javadoc for XMLGregorianCalendar is right - this is legal (the result is a time point of 00:00:00 the next day).

      ----
      hour getHour() 0 to 24 or DatatypeConstants.FIELD_UNDEFINED. For a value of 24, the minute and second field must be zero per XML Schema Errata.
      ----

      The implementation rejects it with an exception calling setHour.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      DatatypeFactory.newInstance().newXMLGregorianCalendar("2008-04-28T24:00:00") ;

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      An XMLGregorian Calendar for 2008-04-29T00:00:00

      This is noted in the javadoc and agrees with the XML Schema datatypes spec and errata. The implementation does not meet the spec.
      ACTUAL -
      java.lang.IllegalArgumentException: Invalid value 24 for Hour field.


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      java.lang.IllegalArgumentException: Invalid value 24 for Hour field.
      at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.checkFieldValueConstraint(Unknown Source)
      at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.setHour(Unknown Source)
      at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl$Parser.parse(Unknown Source)
      at org.apache.xerces.jaxp.datatype.XMLGregorianCalendarImpl.<init>(Unknown Source)
      at org.apache.xerces.jaxp.datatype.DatatypeFactoryImpl.newXMLGregorianCalendar(Unknown Source)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      DatatypeFactory.newInstance().newXMLGregorianCalendar("2008-04-28T24:00:00") ;
      ---------- END SOURCE ----------

            joehw Joe Wang
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: