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

Bad xml date time format

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 6u22
    • xml
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.6.0_02"
      Java(TM) SE Runtime Environment (build 1.6.0_02-b05)
      Java HotSpot(TM) Client VM (build 1.6.0_02-b05, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Windows XP Professional SP3

      A DESCRIPTION OF THE PROBLEM :
      Bad XML Data time format produced by class XMLGregorianCalendar.

      Actual format is:
      '[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}(:[0-9]{2}(\.[0-9]{3})?((-|\+)[0-9]{2}:[0-9]{2})?)?)?'

      Must be:
      '[0-9]{4}-[0-9]{2}-[0-9]{2}(T[0-9]{2}:[0-9]{2}(:[0-9]{2}(\.[0-9]{6})?((-|\+)[0-9]{2}:[0-9]{2})?)?)?'

      In milliseconds must be add tree zeros 000, see:
      http://www.w3.org/TR/xmlschema-2/#dateTime-order
      3.2.7.1 Lexical representation

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :

      XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());
      System.out.println(cal.toXMLFormat());

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      2010-10-26T18:40:41.265000-05:00
      ACTUAL -
      2010-10-26T18:40:41.265-05:00

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.util.GregorianCalendar;

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


      public class Testmain {

      public static void main(String[] args) {

      try {
      XMLGregorianCalendar cal = DatatypeFactory.newInstance().newXMLGregorianCalendar(new GregorianCalendar());
      System.out.println(cal.toXMLFormat());
      } catch (DatatypeConfigurationException e) {

      e.printStackTrace();
      }
      }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Make my own class date time formatter.

            joehw Joe Wang
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: