-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8, 9
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
A DESCRIPTION OF THE PROBLEM :
java.time.Duration#between(LocalDate, LocalDate) will always throw an exception.
java.time.LocalDate#until(Temporal, TemporalUnit) does not accept NANOS or SECONDS as the ChronoUnit type, which is what is called from Duration.between
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java.time.Duration duration = java.time.Duration.between(java.time.LocalDate.of(2017, 1, 1), java.time.LocalDate.of(2017, 1, 2));
// This will always throw an exception instead of returning a duration of one day
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should return a Duration of one day instead of throwing an error.
ACTUAL -
throws UnsupportedTemporalTypeException("Unsupported unit: SECONDS");
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds
at java.time.LocalDate.until(LocalDate.java:1614)
at java.time.Duration.between(Duration.java:475)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
java.time.Duration duration = java.time.Duration.between(java.time.LocalDate.of(2017, 1, 1), java.time.LocalDate.of(2017, 1, 2));
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
ChronoUnit.DAYS.between(LocalDate, LocalDate)
not an exact workaround, but gets the number of days (which is what I needed)
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
A DESCRIPTION OF THE PROBLEM :
java.time.Duration#between(LocalDate, LocalDate) will always throw an exception.
java.time.LocalDate#until(Temporal, TemporalUnit) does not accept NANOS or SECONDS as the ChronoUnit type, which is what is called from Duration.between
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
java.time.Duration duration = java.time.Duration.between(java.time.LocalDate.of(2017, 1, 1), java.time.LocalDate.of(2017, 1, 2));
// This will always throw an exception instead of returning a duration of one day
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
It should return a Duration of one day instead of throwing an error.
ACTUAL -
throws UnsupportedTemporalTypeException("Unsupported unit: SECONDS");
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds
at java.time.LocalDate.until(LocalDate.java:1614)
at java.time.Duration.between(Duration.java:475)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
java.time.Duration duration = java.time.Duration.between(java.time.LocalDate.of(2017, 1, 1), java.time.LocalDate.of(2017, 1, 2));
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
ChronoUnit.DAYS.between(LocalDate, LocalDate)
not an exact workaround, but gets the number of days (which is what I needed)