package com.logicbig.example.monthday;
import java.time.MonthDay;
import java.time.temporal.ChronoField;
import java.time.temporal.UnsupportedTemporalTypeException;
public class GetExample {
public static void main(String... args) {
MonthDay m = MonthDay.of(5, 21);
System.out.println(m);
for (ChronoField field : ChronoField.values()) {
try {
int i = m.get(field);
System.out.printf("%12s > %s%n", field, i);
} catch (UnsupportedTemporalTypeException e) {
System.out.printf(" -- %s not supported%n", field);
}
}
}
}
Output
--05-21
-- NanoOfSecond not supported
-- NanoOfDay not supported
-- MicroOfSecond not supported
-- MicroOfDay not supported
-- MilliOfSecond not supported
-- 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 > 21
-- DayOfYear not supported
-- EpochDay not supported
-- AlignedWeekOfMonth not supported
-- AlignedWeekOfYear not supported
MonthOfYear > 5
-- ProlepticMonth not supported
-- YearOfEra not supported
-- Year not supported
-- Era not supported
-- InstantSeconds not supported
-- OffsetSeconds not supported