-
Bug
-
Resolution: Won't Fix
-
P2
-
6u18
-
sparc
-
solaris_10
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2190825 | 7 | Joe Wang | P2 | Closed | Fixed | b112 |
JDK-2192218 | 1.4.0 | Joe Wang | P2 | Closed | Fixed | 1.4 |
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.).
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.).
- backported by
-
JDK-2190825 XMLGregorianCalendar do not handle T24:00:00 correctly
- Closed
-
JDK-2192218 XMLGregorianCalendar do not handle T24:00:00 correctly
- Closed