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

XMLGregorianCalendar.add counts months from 1 to 11 instead of from 1 to 12

    Details

    • Subcomponent:
    • Resolved In Build:
      1.3
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Name: erR10175 Date: 03/31/2004



           The method the class javax.xml.datatype.XMLGregorianCalendar

        public void add(Duration duration)

        incorrectly modifies the XMLGregorianCalendar representation of
        the date "2000-01-01T00:00:00Z" when one day is subtracted from it. The result of
        the method call is "1999-11-30T00:00:00Z", but it should be "1999-12-31T00:00:00Z".

        The bug affects the following new JCK-15 beta2 test:

          api/javax_xml/datatype/XMLGregorianCalendar/index.html#Add[Add003]

        The bug is found in jdk1.5.0/beta2/b44. The test is in KFL with the RI bug

        4972801 XMLGregorianCalendar.parse cannot parse long years

        To reproduce the bug compile and run the following code as shown in the log below.
        ------------------------------------------ test.java
        import javax.xml.datatype.XMLGregorianCalendar;
        import javax.xml.datatype.Duration;

        class test {

            public static void main(String [] args) {
                XMLGregorianCalendar calendar
                    = XMLGregorianCalendar.parse("2000-01-01T00:00:00Z");
                XMLGregorianCalendar expected
                    = XMLGregorianCalendar.parse("1999-12-31T00:00:00Z");
                calendar.add(new Duration("-P1D"));
                if (!calendar.equals(expected)) {
                    System.out.println("returned: " + calendar.toXMLFormat());
                    System.out.println("expected: " + expected.toXMLFormat());
                } else {
                    System.out.println("OK");
                }
            }
        }
        ----------------------------------------------------

        ------------------------------------------------ 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-b44)
        Java HotSpot(TM) Server VM (build 1.5.0-beta2-b44, mixed mode)

        returned: 1999-11-30T00:00:00Z
        expected: 1999-12-31T00:00:00Z
        ----------------------------------------------------

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

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jsuttorsunw Jeff Suttor (Inactive)
                  Reporter:
                  reysunw Rey Rey (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  0 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: