-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
b58
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2100317 | 5.0 | Jeff Suttor | P3 | Resolved | Fixed | rc |
Name: erR10175 Date: 06/17/2004
The following method of the class javax.xml.datatype.XMLGregorianCalendar
public abstract XMLGregorianCalendar normalize()
changes timezone of the calendar from undefined to UTC. Also, the method
changes millisecond field from undefined to 0.
The javadoc of the method refers to the W3C XML Schema Part 2, Section 3.2.7.3
which reads:
"
A.Normalize P and Q. That is, if there is a timezone present, but it is not Z,
convert it to Z using the addition operation defined in Adding durations
to dateTimes
"
So in both cases (UTC and undefined) the method should leave
the XMLGregorianCalendar instance unchanged.
This bug affects new test in JCK 1.5
api/javax_xml/datatype/XMLGregorianCalendar/index.html#Normalize[Normalize001]
The bug is found in jdk15-b55 and jaxp13-b19 after the fix of following RI
bug is integrated:
5048932 XMLGregorianCalendar.normalize throws IllegalArgumentException
To reproduce the bug compile and run the following code as shown in the log below.
--------------------------- test.java
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.datatype.DatatypeFactory;
class test {
static final String [] normalizeValues = {
"2000-01-16T00:00:00.01Z",
"2000-01-16T00:00:00.01",
"13:20:00",
};
static String ifdef(int value) {
return value == DatatypeConstants.FIELD_UNDEFINED
? "FIELD_UNDEFINED"
: (""+value);
}
public static void main(String [] args) throws Exception {
DatatypeFactory df = DatatypeFactory.newInstance();
String status = "Passed.";
for(int i = 0; i < normalizeValues.length; ++i) {
XMLGregorianCalendar orig = df.newXMLGregorianCalendar(normalizeValues[i]);
XMLGregorianCalendar normalized = df.newXMLGregorianCalendar(normalizeValues[i])
.normalize();
if (orig.getTimezone() != normalized.getTimezone()) {
System.out.println("Failed for " + normalizeValues[i]
+ ": original timezone has been changed "
+ "by the method normalize: original = " + ifdef(orig.getTimezone())
+ ", normalized = " + ifdef(normalized.getTimezone()));
status = "Failed.";
}
if (orig.getMillisecond() != normalized.getMillisecond()) {
System.out.println("Failed for " + normalizeValues[i]
+ ": original millisecond field has been changed "
+ "by the method normalize: original = " + ifdef(orig.getMillisecond())
+ ", normalized = " + ifdef(normalized.getMillisecond()));
status = "Failed.";
}
}
System.out.println(status);
}
}
-------------------------------------
--------------------------------- log
$javac test.java && java -showversion -cp . test
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b55)
Java HotSpot(TM) Client VM (build 1.5.0-beta3-b55, mixed mode)
Failed for 2000-01-16T00:00:00.01: original timezone has been changed by the method normalize: original = FIELD_UNDEFINED, normalized = 0
Failed for 13:20:00: original timezone has been changed by the method normalize: original = FIELD_UNDEFINED, normalized = 0
Failed for 13:20:00: original millisecond field has been changed by the method normalize: original = FIELD_UNDEFINED, normalized = 0
Failed.
-------------------------------------
======================================================================
The following method of the class javax.xml.datatype.XMLGregorianCalendar
public abstract XMLGregorianCalendar normalize()
changes timezone of the calendar from undefined to UTC. Also, the method
changes millisecond field from undefined to 0.
The javadoc of the method refers to the W3C XML Schema Part 2, Section 3.2.7.3
which reads:
"
A.Normalize P and Q. That is, if there is a timezone present, but it is not Z,
convert it to Z using the addition operation defined in Adding durations
to dateTimes
"
So in both cases (UTC and undefined) the method should leave
the XMLGregorianCalendar instance unchanged.
This bug affects new test in JCK 1.5
api/javax_xml/datatype/XMLGregorianCalendar/index.html#Normalize[Normalize001]
The bug is found in jdk15-b55 and jaxp13-b19 after the fix of following RI
bug is integrated:
5048932 XMLGregorianCalendar.normalize throws IllegalArgumentException
To reproduce the bug compile and run the following code as shown in the log below.
--------------------------- test.java
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.datatype.DatatypeFactory;
class test {
static final String [] normalizeValues = {
"2000-01-16T00:00:00.01Z",
"2000-01-16T00:00:00.01",
"13:20:00",
};
static String ifdef(int value) {
return value == DatatypeConstants.FIELD_UNDEFINED
? "FIELD_UNDEFINED"
: (""+value);
}
public static void main(String [] args) throws Exception {
DatatypeFactory df = DatatypeFactory.newInstance();
String status = "Passed.";
for(int i = 0; i < normalizeValues.length; ++i) {
XMLGregorianCalendar orig = df.newXMLGregorianCalendar(normalizeValues[i]);
XMLGregorianCalendar normalized = df.newXMLGregorianCalendar(normalizeValues[i])
.normalize();
if (orig.getTimezone() != normalized.getTimezone()) {
System.out.println("Failed for " + normalizeValues[i]
+ ": original timezone has been changed "
+ "by the method normalize: original = " + ifdef(orig.getTimezone())
+ ", normalized = " + ifdef(normalized.getTimezone()));
status = "Failed.";
}
if (orig.getMillisecond() != normalized.getMillisecond()) {
System.out.println("Failed for " + normalizeValues[i]
+ ": original millisecond field has been changed "
+ "by the method normalize: original = " + ifdef(orig.getMillisecond())
+ ", normalized = " + ifdef(normalized.getMillisecond()));
status = "Failed.";
}
}
System.out.println(status);
}
}
-------------------------------------
--------------------------------- log
$javac test.java && java -showversion -cp . test
java version "1.5.0-beta3"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta3-b55)
Java HotSpot(TM) Client VM (build 1.5.0-beta3-b55, mixed mode)
Failed for 2000-01-16T00:00:00.01: original timezone has been changed by the method normalize: original = FIELD_UNDEFINED, normalized = 0
Failed for 13:20:00: original timezone has been changed by the method normalize: original = FIELD_UNDEFINED, normalized = 0
Failed for 13:20:00: original millisecond field has been changed by the method normalize: original = FIELD_UNDEFINED, normalized = 0
Failed.
-------------------------------------
======================================================================
- backported by
-
JDK-2100317 XMLGregorianCalendar.normalize changes undefined timezone to UTC
- Resolved
- relates to
-
JDK-5048932 XMLGregorianCalendar.normalize throws IllegalArgumentException
- Resolved