Year range() method in Java with Examples
range() method of the Year class is used to get the range of field in terms of the minimum and maximum values and the field is passed as a parameter to this method. The returned value for this method is ValueRange object for the field and the method returns ValueRange object only for those fields which are supported by Year object. So when the field is not supported by this method, an exception is thrown by this method.
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:
Range in ERA: 0 - 1
Range in YEAR: -999999999 - 999999999
Please Login to comment...