Checks if the specified temporal field is supported by this Year object.
Checks if the specified temporal unit is supported by this Year object.
package com.logicbig.example.year;
import java.time.Year;
import java.time.temporal.ChronoField;
public class IsSupportedExample {
public static void main(String... args) {
Year y = Year.of(2011);
System.out.println(y);
for (ChronoField field : ChronoField.values()) {
boolean b = y.isSupported(field);
System.out.printf("%23s > %s%n", field, b);
}
}
}
Output
2011
NanoOfSecond > false
NanoOfDay > false
MicroOfSecond > false
MicroOfDay > false
MilliOfSecond > false
MilliOfDay > false
SecondOfMinute > false
SecondOfDay > false
MinuteOfHour > false
MinuteOfDay > false
HourOfAmPm > false
ClockHourOfAmPm > false
HourOfDay > false
ClockHourOfDay > false
AmPmOfDay > false
DayOfWeek > false
AlignedDayOfWeekInMonth > false
AlignedDayOfWeekInYear > false
DayOfMonth > false
DayOfYear > false
EpochDay > false
AlignedWeekOfMonth > false
AlignedWeekOfYear > false
MonthOfYear > false
ProlepticMonth > false
YearOfEra > true
Year > true
Era > true
InstantSeconds > false
OffsetSeconds > false
package com.logicbig.example.year;
import java.time.Year;
import java.time.temporal.ChronoField;
import java.time.temporal.ChronoUnit;
public class IsSupportedExample2 {
public static void main(String... args) {
Year y = Year.of(2011);
System.out.println(y);
for (ChronoUnit field : ChronoUnit.values()) {
boolean b = y.isSupported(field);
System.out.printf("%10s > %s%n", field, b);
}
}
}
Output
2011
Nanos > false
Micros > false
Millis > false
Seconds > false
Minutes > false
Hours > false
HalfDays > false
Days > false
Weeks > false
Months > false
Years > true
Decades > true
Centuries > true
Millennia > true
Eras > true
Forever > false