Uploaded image for project: 'Tuscany'
  1. Tuscany
  2. TUSCANY-1044

DataHelperImpl.toDateTime() is not compliant with spec.

    XMLWordPrintableJSON

Details

    Description

      Ron,

      I think you are correct. The spec says ...

      The String representation of DateTime, Duration, Time, Day, Month, MonthDay,
      Year, YearMonth, and YearMonthDay follows the lexical representation defined
      in XML Schema for the corresponding data types: dateTime, duration, time,
      gDay, gMonth, gMonthDay, gYear, gYearMonth, and Date respectively.

      and the XML schema definition at
      http://www.w3.org/TR/xmlschema-2/#dateTime-timezones seems to be overriden
      by the errata at http://www.w3.org/2001/05/xmlschema-errata#e2-45 which
      gives ...

      The lexical representation of a timezone is a string of the form: (('+' |
      '-') hh ':' mm) | 'Z', where hh is a two-digit numeral (with leading zeros
      as required) that represents the hours, mm is a two-digit numeral that
      represents the minutes, '+' indicates a nonnegative duration, and '-'
      indicates a nonpositive duration. The mapping so defined is one-to-one,
      except that '+00:00', '00:00', and 'Z' all represent the same zero-length
      duration timezone, UTC; 'Z' is its canonical representation.

      so please raise a JIRA, and of course I have to say it ... a fix would be
      great too

      Cheers, Kelvin.

      On 09/01/07, Ron Gavlin <rgavlin@yahoo.com> wrote:
      >
      > Greetings,
      >
      > Based on my reading of the spec, DataHelperImpl.toDateTime(Calendar)
      > should return a String compatible with the XML Schema dateTime. Consider the
      > code snippet below:
      >
      > import commonj.sdo.helper.DataHelper;
      >
      > System.out.println(DataHelper.INSTANCE.toDateTime(
      > DataHelper.INSTANCE.toCalendar("2007-01-01T00:00:00.200Z"))
      >
      > This snippet prints the result:
      > (java.lang.String) 2007-01-01T00:00:00.200 GMT
      >
      > instead of
      > (java.lang.String) 2007-01-01T00:00:00.200Z
      >
      > The GMT suffix seems incorrect to me. The following code supports this
      > assertion by throwing an IllegalArgumentException when it encounters the "
      > GMT" suffix generated by the DataHelper.toDateTime() method.
      >
      > import javax.xml.datatype.DatatypeFactory;
      >
      > DatatypeFactory.newInstance().newXMLGregorianCalendar("2007-01-01T00:00:
      > 00.200 GMT");
      >
      > Do you agree this is a bug? If so, I'll be glad to open a JIRA.
      >
      > - Ron

      Attachments

        1. DateTimeTest.zip
          6 kB
          Hasan Muhammad
        2. DateTime.patch
          0.6 kB
          Hasan Muhammad

        Activity

          People

            Unassigned Unassigned
            rgavlin Ron Gavlin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: