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

toString method of XMLGregorianCalendar does not return a valid dateTime value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 7
    • xml
    • 1.4
    • generic
    • generic
    • Verified

        From jaxp issue 12:
        toString method of XMLGregorianCalendar does not return a valid dateTime value.
        The output contains an exponent notation in millisecond value.

        The following sample will create an XMLGregorianCalendar from
        2006-10-23T22:15:01.0000001+08:00, but toString will print a different and an
        invalid dateTime which is 2006-10-23T22:15:01E-7+08:00


        package org.gs1us.xml.test;

        import javax.xml.datatype.DatatypeFactory;
        import javax.xml.datatype.XMLGregorianCalendar;

        /**
         * @author nalmodiel
         */
        public class XMLGregorianCalendarSample {

          public static void main(String[] args) {

            try {
        String inputDateTime = "2006-10-23T22:15:01.0000001+08:00";
        DatatypeFactory factory = DatatypeFactory.newInstance();
        XMLGregorianCalendar calendar =
        factory.newXMLGregorianCalendar(inputDateTime);

        System.out.println(calendar.toString());
            }
            catch (Exception e) {
        e.printStackTrace();
            }
          }
        }

        ------- Additional comments from ndw Mon Oct 23 21:10:56 +0000 2006 -------

        Added a unit test to the build. Working on it.

        ------- Additional comments from ndw Thu Nov 16 19:47:07 +0000 2006 -------

        The fix for this is now in the HEAD

              joehw Joe Wang
              joehw Joe Wang
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: