package com.logicbig.example.instant;
import java.time.Instant;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;
public class RangeExample {
public static void main(String... args) {
Instant i = Instant.now();
System.out.println(i);
for (ChronoField field : ChronoField.values()) {
try {
ValueRange r = i.range(field);
System.out.printf("%15s > %s%n", field, r);
} catch (Exception e) {
System.out.printf("--%s not supported%n", field);
}
}
}
}
Output
2017-05-01T20:57:07.860Z
NanoOfSecond > 0 - 999999999
--NanoOfDay not supported
MicroOfSecond > 0 - 999999
--MicroOfDay not supported
MilliOfSecond > 0 - 999
--MilliOfDay not supported
--SecondOfMinute not supported
--SecondOfDay not supported
--MinuteOfHour not supported
--MinuteOfDay not supported
--HourOfAmPm not supported
--ClockHourOfAmPm not supported
--HourOfDay not supported
--ClockHourOfDay not supported
--AmPmOfDay not supported
--DayOfWeek not supported
--AlignedDayOfWeekInMonth not supported
--AlignedDayOfWeekInYear not supported
--DayOfMonth not supported
--DayOfYear not supported
--EpochDay not supported
--AlignedWeekOfMonth not supported
--AlignedWeekOfYear not supported
--MonthOfYear not supported
--ProlepticMonth not supported
--YearOfEra not supported
--Year not supported
--Era not supported
InstantSeconds > -9223372036854775808 - 9223372036854775807
--OffsetSeconds not supported