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

jaxp issue 12: toString method of XMLGregorianCalendar does not return a valid dateTime value

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 7
    • xml
    • b14
    • generic
    • generic

        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();
            }
          }
        }

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

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: