MonthDay range() method in Java with Examples Last Updated : 28 Jan, 2019 Comments Improve Suggest changes Like Article Like Report range() method of the MonthDay class used to get the ValueRange object which is the range of field in terms of the minimum and maximum values for the field passed as a parameter to this method. The method returns ValueRange object only for those fields which are supported by MonthDay object. So when the field is not supported by this method then an exception is thrown by this method. Syntax: public ValueRange range(TemporalField field) Parameters: This method accepts one parameter field which is the field to query the range. Return value: This method returns the range of valid values for the field. Exception:This method throws following Exceptions: DateTimeException – if the range for the field cannot be obtained. UnsupportedTemporalTypeException – if the field is not supported. Below programs illustrate the range() method: Program 1: Java // Java program to demonstrate // MonthDay.range() method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create MonthDay objects MonthDay monthDay = MonthDay.parse("--12-06"); // apply range() method of MonthDay class ValueRange result = monthDay.range(ChronoField.MONTH_OF_YEAR); // print results System.out.println("Range in MONTH_OF_YEAR: " + result); } } Output: Range in MONTH_OF_YEAR: 1 - 12 Program 2: Java // Java program to demonstrate // MonthDay.range() method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create MonthDay objects MonthDay monthDay = MonthDay.parse("--12-06"); // apply range() method of MonthDay class ValueRange result = monthDay.range(ChronoField.DAY_OF_MONTH); // print results System.out.println("Range in DAY_OF_MONTH: " + result); } } Output: Range in DAY_OF_MONTH: 1 - 31 References: https://docs.oracle.com/javase/10/docs/api/java/time/MonthDay.html#range(java.time.temporal.TemporalField) Comment More infoAdvertise with us Next Article MonthDay range() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Java-time package Java-MonthDay Practice Tags : Java Similar Reads MonthDay query() method in Java with Examples query() method of an MonthDay class used to query this MonthDay using the specified query as parameter.The TemporalQuery object passed as parameter define the logic to be used to obtain the result from this MonthDay. Syntax: public <R> R query(TemporalQuery<R> query) Parameters: This met 2 min read MonthDay get() method in Java with Examples The get() method of MonthDay class in Java gets the value of the specified field from this month-day as an int. Syntax: public int get(TemporalField field) Parameter: This method accepts a parameter field which specifies the field to get and not null. Returns: The function returns the value for the 2 min read MinguoDate range() method in Java with Example The range() method of java.time.chrono.MinguoDate class is used get the range of from the specified field of type TemporalField. Syntax: public ValueRange range(TemporalField field) Parameter: This method takes the field of type TemporalField as a parameter whose range is to be obtained. Return Valu 2 min read MonthDay from() method in Java with Examples The from() method of MonthDay class in Java obtains an instance of MonthDay from a temporal object. Syntax: public static MonthDay from(TemporalAccessor temporal) Parameter: This method accepts a parameter temporal which specifies the temporal object to convert which is not null. Returns: The functi 1 min read OffsetDateTime range() method in Java with Examples The range() method of the OffsetDateTime class used to get the ValueRange object which is the range of field in terms of the minimum and maximum values for the field passed as a parameter to this method. The method returns ValueRange object only for those fields which are supported by OffsetDateTime 2 min read Like