FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux bds01237.bds-ad.lc 4.11.12-200.fc25.x86_64 #1 SMP Fri Jul 21 16:41:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
DateTimeFormatter.ISO_LOCAL_DATE.format() throws exception when given the result of Instant.ofEpochSecond().
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See "Source code for an executable test case"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Something similar to the output of date; e.g.,
$ date -d @934948800
Wed Aug 18 00:00:00 EDT 1999
ACTUAL -
An UnsupportedTemporalTypeException is thrown
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: Year
at java.time.Instant.getLong(Instant.java:603)
at java.time.format.DateTimePrintContext$1.getLong(DateTimePrintContext.java:205)
at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298)
at java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2540)
at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2179)
at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1746)
at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1720)
at ConvertFromEpochSeconds.main(ConvertFromEpochSeconds.java:8)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.time.Instant;
import java.time.format.DateTimeFormatter;
public class ConvertFromEpochSeconds {
public static void main(String[] argv) {
Instant inst = Instant.ofEpochSecond(934948800L);
String formatted = DateTimeFormatter.ISO_LOCAL_DATE.format(inst);
System.out.println(formatted);
}
}
---------- END SOURCE ----------
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Linux bds01237.bds-ad.lc 4.11.12-200.fc25.x86_64 #1 SMP Fri Jul 21 16:41:43 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
A DESCRIPTION OF THE PROBLEM :
DateTimeFormatter.ISO_LOCAL_DATE.format() throws exception when given the result of Instant.ofEpochSecond().
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See "Source code for an executable test case"
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Something similar to the output of date; e.g.,
$ date -d @934948800
Wed Aug 18 00:00:00 EDT 1999
ACTUAL -
An UnsupportedTemporalTypeException is thrown
ERROR MESSAGES/STACK TRACES THAT OCCUR :
Exception in thread "main" java.time.temporal.UnsupportedTemporalTypeException: Unsupported field: Year
at java.time.Instant.getLong(Instant.java:603)
at java.time.format.DateTimePrintContext$1.getLong(DateTimePrintContext.java:205)
at java.time.format.DateTimePrintContext.getValue(DateTimePrintContext.java:298)
at java.time.format.DateTimeFormatterBuilder$NumberPrinterParser.format(DateTimeFormatterBuilder.java:2540)
at java.time.format.DateTimeFormatterBuilder$CompositePrinterParser.format(DateTimeFormatterBuilder.java:2179)
at java.time.format.DateTimeFormatter.formatTo(DateTimeFormatter.java:1746)
at java.time.format.DateTimeFormatter.format(DateTimeFormatter.java:1720)
at ConvertFromEpochSeconds.main(ConvertFromEpochSeconds.java:8)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.time.Instant;
import java.time.format.DateTimeFormatter;
public class ConvertFromEpochSeconds {
public static void main(String[] argv) {
Instant inst = Instant.ofEpochSecond(934948800L);
String formatted = DateTimeFormatter.ISO_LOCAL_DATE.format(inst);
System.out.println(formatted);
}
}
---------- END SOURCE ----------