Error
java.time.temporal.UnsupportedTemporalTypeException: Invalid field 'MicroOfDay' for get() method, use getLong() instead
at java.time.LocalTime.get0(LocalTime.java:666)
at java.time.LocalTime.get(LocalTime.java:619)
at java.time.LocalDateTime.get(LocalDateTime.java:688)
at java.time.ZonedDateTime.get(ZonedDateTime.java:820)
Error Type
Run Time
Sample Code
ZonedDateTime zonedDatetime = ZonedDateTime.of(2015, 1, 31, 14, 35, 12, 123, ZoneId.of("UTC-11"));
System.out.println(zonedDatetime.get(ChronoField.MICRO_OF_DAY));
Cause
Cause
UnsupportedTemporalTypeException is thrown when this temporal type is not supported for the specific operation. In this case ChronoField.MICRO_OF_DAY is not supported because it exceds the capacity of an integer which the get method is supposed to return.
Resolution
Use some other Temporal Field which is supported for this operation.
System.out.println(zonedDatetime.get(ChronoField.HOUR_OF_DAY));