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

XMLGregorianCalendar.parse cannot parse long years

XMLWordPrintable

    • b35
    • generic
    • generic
    • Verified



      Name: erR10175 Date: 12/25/2003


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

      public static XMLGregorianCalendar parse(String lexicalRepresentation)

      cannot parse long years. Parsing the valid date '2000000000000000000000001-01-01'
      throws NumberFormatException.

      According to the XML Schema Part 2 Datatypes, lexical representation of date
      types may contain arbitrary big year values. Javadoc of the method does not
      specify any limitation.

      This bug affects new tests in JCK 1.5 (not integrated yet)
          api/javax_xml/datatype/XMLGregorianCalendar/index.html#Add[Add003]
          api/javax_xml/datatype/XMLGregorianCalendar/index.html#GetSetCreate[Clear001]

      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.parse("2000000000000000000000001-01-01");
              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)

      Exception in thread "main" java.lang.NumberFormatException: For input string: "2000000000000000000000001"
              at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
              at java.lang.Integer.parseInt(Integer.java:458)
              at java.lang.Integer.parseInt(Integer.java:496)
              at javax.xml.datatype.XMLGregorianCalendar$Parser.parseInt(XMLGregorianCalendar.java:2576)
              at javax.xml.datatype.XMLGregorianCalendar$Parser.parse(XMLGregorianCalendar.java:2479)
              at javax.xml.datatype.XMLGregorianCalendar.<init>(XMLGregorianCalendar.java:457)
              at javax.xml.datatype.XMLGregorianCalendar.parse(XMLGregorianCalendar.java:1486)
              at test.main(test.java:5)
      ----------------------------------------------------

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

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: