·
Given:
What is the output?
A)
P1Y
PT8784H
B)
PT8784H
P1Y
C)
UnsupportedTemporalTypeException
D)
P1Y
UnsupportedTemporalTypeException
E)
PT8784H
UnsupportedTemporalTypeException
#java #certificationquestion #ocp
P1Y
java.time.temporal.UnsupportedTemporalTypeException: Unsupported unit: Seconds
at java.base/java.time.LocalDate.until(LocalDate.java:1636)
at java.base/java.time.Duration.between(Duration.java:489)
Period works well with LocalDate, while Duration no.
Because duration works with Time and according to JavaDoc:
"The specified temporal objects must support the SECONDS unit. For full accuracy, either the NANOS unit or the NANO_OF_SECOND field should be supported."