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

XMLGregorianCalendar do not handle T24:00:00 correctly

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_10

      Backports

        Description

        XMLGregorianCalendar do not handle T24:00:00 correctly.
        Midnight is the same moment as the start of the next day,
        but this test case shows otherwise

        Expected output: pass
        Actual output: fail

        import javax.xml.datatype.*;
        public class Bug {
         public static void main(String[] args) throws DatatypeConfigurationException {
           DatatypeFactory dtf = DatatypeFactory.newInstance();
             XMLGregorianCalendar c1 = dtf.newXMLGregorianCalendar("1999-12-31T24:00:00");
             XMLGregorianCalendar c2 = dtf.newXMLGregorianCalendar("2000-01-01T00:00:00");
             System.out.println(c1.equals(c2) ? "pass" : "fail"); // fails
           }
        }

        W3C XML Schema (http://www.w3.org/TR/xmlschema-2)

         The algorithm in section 3.2.7.4 operates on the value
        space. "1999-12-31T24:00:00" is valid in the lexical space, but section
        3.2.7.2 clearly states that 24 is not a valid value (in the value space) for
        hours. It MUST be transformed, according to section 3.2.7.1, to the first
        instant of the following day, i.e. "2000-01-01T00:00:00". Thus, according to
        the spec, these 2 different lexical values map to the exact same point in the
        value space, and thus are indeed equal by definition.

        3.2.7.2 Canonical representation

        Except for trailing fractional zero digits in the seconds representation, '24:00:00' time representations, and timezone (for timezoned values), the mapping from literals to values is one-to-one. Where there is more than one possible representation, the canonical representation is as follows:

            * The 2-digit numeral representing the hour must not be '24';
            * The fractional second string, if present, must not end in '0';
            * for timezoned values, the timezone must be represented with 'Z' (All timezoned dateTime values are UTC.).

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  coffeys Sean Coffey
                  Reporter:
                  lkchow Lawrence Chow
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: