Returns the range of valid values for the specified field.
package com.logicbig.example.monthday;
import java.time.MonthDay;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;
public class RangeExample {
public static void main(String... args) {
MonthDay m = MonthDay.now();
System.out.println(m);
for (ChronoField field : ChronoField.values()) {
if (m.isSupported(field)) {
ValueRange range = m.range(field);
System.out.printf("%15s > %s%n", field, range);
}
}
}
}
Output
--05-01
DayOfMonth > 1 - 31
MonthOfYear > 1 - 12