Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2076192 | 5.0 | Kohsuke Kawaguchi | P3 | Closed | Fixed | b30 |
Name: erR10175 Date: 10/22/2003
Constructor javax.xml.datatype.Duration.Duration(long durationInMilliSeconds)
works with negative milliseconds incorrectly:
new Duration(-1L) creates duration "P0DT0.001S" instead of expected "PT0.001S";
new Duration(0x8000000000000000L) creates duration which is printed
as "P-106751991167DT-7H-12M-55.808S", expected is "-P106751991167DT7H12M55.808S".
The documentation of the constructor does not explicitly forbid to use negative
values for the argument 'durationInMilliSeconds'. So the expected behaviour
is to create a duration with negative sign and with length of the absolute
value of the durationInMilliSeconds.
This bug affects new test in JCK 1.5 (not yet integrated)
api/javax_xml/datatype/Duration/index.html#DurationTests[Ctor007]
To reproduce the bug compile and run the following code as shown
in the log below:
------------------------------ test.java
import javax.xml.datatype.Duration;
public class test {
public static void main(String [] args) {
System.out.println("created: "
+ new Duration(-1L)
+ ", expected: -PT0.001S");
System.out.println("created: "
+ new Duration(0x8000000000000000L)
+ ", expected: -P106751991167DT7H12M55.808S");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java
$java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b24)
Java HotSpot(TM) Server VM (build 1.5.0-beta-b24, mixed mode)
created: P0DT0.001S, expected: -PT0.001S
created: P-106751991167DT-7H-12M-55.808S, expected: -P106751991167DT7H12M55.808S
----------------------------------------------------
======================================================================
Constructor javax.xml.datatype.Duration.Duration(long durationInMilliSeconds)
works with negative milliseconds incorrectly:
new Duration(-1L) creates duration "P0DT0.001S" instead of expected "PT0.001S";
new Duration(0x8000000000000000L) creates duration which is printed
as "P-106751991167DT-7H-12M-55.808S", expected is "-P106751991167DT7H12M55.808S".
The documentation of the constructor does not explicitly forbid to use negative
values for the argument 'durationInMilliSeconds'. So the expected behaviour
is to create a duration with negative sign and with length of the absolute
value of the durationInMilliSeconds.
This bug affects new test in JCK 1.5 (not yet integrated)
api/javax_xml/datatype/Duration/index.html#DurationTests[Ctor007]
To reproduce the bug compile and run the following code as shown
in the log below:
------------------------------ test.java
import javax.xml.datatype.Duration;
public class test {
public static void main(String [] args) {
System.out.println("created: "
+ new Duration(-1L)
+ ", expected: -PT0.001S");
System.out.println("created: "
+ new Duration(0x8000000000000000L)
+ ", expected: -P106751991167DT7H12M55.808S");
}
}
----------------------------------------------------
------------------------------------------------ log
$javac test.java
$java -cp . -showversion test
java version "1.5.0-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b24)
Java HotSpot(TM) Server VM (build 1.5.0-beta-b24, mixed mode)
created: P0DT0.001S, expected: -PT0.001S
created: P-106751991167DT-7H-12M-55.808S, expected: -P106751991167DT7H12M55.808S
----------------------------------------------------
======================================================================
- backported by
-
JDK-2076192 Duration(long durationInMilliSeconds) incorrectly works with negative arguments
- Closed