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

XMLGregorianCalendar.toXMLFormat does not throw IllegalStateException

    XMLWordPrintable

Details

    • b35
    • generic
    • generic
    • Verified

    Description


      Name: erR10175 Date: 12/26/2003


       
        The following methods of the class javax.xml.datatype.XMLGregorianCalendar

      public QName getXMLSchemaType()
      public String toXMLFormat()

      do not throw IllegalStateException if the combination of specified fields
      does not match one of the eight defined XML Schema builtin date/time datatypes.

      According to the table in the description of the method getXMLSchemaType(),
      there is no XML Schema builtin date/time datatype which corresponds to an
      XMLGregorianCalendar instance with the following fields specified:
      Year, Month, Day, Hour, Second. For such a value the methods should throw
      IllegalStateException, but getXMLSchemaType() returns type dateTime
      and toXMLFormat() returns the invalid lexical representation
      '1970-01-01T00:-2147483648:00'.

      This bug affects new test in JCK 1.5 (not integrated yet)
          api/javax_xml/datatype/XMLGregorianCalendar/index.html#ToXML[GetXMLSchemaType002]
          api/javax_xml/datatype/XMLGregorianCalendar/index.html#ToXML[ToXMLFormat001]

      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) {
              try {
                  XMLGregorianCalendar calendar
                      = XMLGregorianCalendar.createDateTime(1970, 1, 1, 0
                          , XMLGregorianCalendar.FIELD_UNDEFINED, 0, 0, 0);

                  System.out.println("Failed: getXMLSchemaType() returns "
                      + calendar.getXMLSchemaType());
                  System.out.println("Failed: toXMLFormat() returns "
                      + calendar.toXMLFormat());
              } catch (IllegalArgumentException e) {
                  System.out.println("OK");
              }
          }
      }
      ----------------------------------------------------

      ------------------------------------------------ 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: getXMLSchemaType() returns {http://www.w3.org/2001/XMLSchema}dateTime
      Failed: toXMLFormat() returns 1970-01-01T00:-2147483648:00.0Z
      ----------------------------------------------------

      ======================================================================

      Attachments

        Activity

          People

            jfialli Joe Fialli
            reysunw Rey Rey (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: