-
Bug
-
Resolution: Fixed
-
P3
-
8u11
-
b94
-
x86_64
-
windows_7
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8174085 | 8-pool | Ramanand Patil | P3 | Open | Unresolved |
FULL PRODUCT VERSION :
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64-bit
A DESCRIPTION OF THE PROBLEM :
First of all sorry if this is not in the correct category, I could not find the relevant category for java.time.*
When parsing a negative Duration with 0 seconds and a few nanoseconds, the nanoseconds are wrongly considered positive:
System.out.println(Duration.parse("PT-1.5S")); // PT-1.5S : ok
System.out.println(Duration.parse("PT-0.5S")); // PT0.5S : error
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println(Duration.parse("PT-0.5S"));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
PT-0.5S
ACTUAL -
PT0.5S
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.company;
import java.time.*;
public class Main {
public static void main(String[] args) {
System.out.println(Duration.parse("PT-0.5S"));
}
}
---------- END SOURCE ----------
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7 64-bit
A DESCRIPTION OF THE PROBLEM :
First of all sorry if this is not in the correct category, I could not find the relevant category for java.time.*
When parsing a negative Duration with 0 seconds and a few nanoseconds, the nanoseconds are wrongly considered positive:
System.out.println(Duration.parse("PT-1.5S")); // PT-1.5S : ok
System.out.println(Duration.parse("PT-0.5S")); // PT0.5S : error
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
System.out.println(Duration.parse("PT-0.5S"));
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
PT-0.5S
ACTUAL -
PT0.5S
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
package com.company;
import java.time.*;
public class Main {
public static void main(String[] args) {
System.out.println(Duration.parse("PT-0.5S"));
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8174085 java.time.Duration.parse() fails for negative duration with 0 seconds and nanos
-
- Open
-
- duplicates
-
JDK-8146173 java.time.Duration.parse examples are incorrect.
-
- Closed
-
-
JDK-8169758 Typo in Javadoc of java.time.Duration:parse
-
- Closed
-
-
JDK-8136513 java.time.Duration.parse() parses negative sub-second text as positive value
-
- Closed
-
- relates to
-
JDK-8273814 Duration.parse() parse '-0' and '0' to same result 0
-
- Closed
-