OffsetTime range() method in Java with Examples Last Updated : 28 Jan, 2019 Comments Improve Suggest changes Like Article Like Report range() method of the OffsetTime class used to get the range in terms of the minimum and maximum values for the field 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 OffsetTime 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 // OffsetTime.range() method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create OffsetTime objects OffsetTime offset = OffsetTime .parse("15:30:30+07:00"); // apply range() method of OffsetTime class ValueRange result = offset.range(ChronoField.OFFSET_SECONDS); // print results System.out.println("Range in OFFSET_SECONDS: " + result); } } Output: Range in OFFSET_SECONDS: -64800 - 64800 Program 2: Java // Java program to demonstrate // OffsetTime.range() method import java.time.*; import java.time.temporal.*; public class GFG { public static void main(String[] args) { // create OffsetTime objects OffsetTime offset = OffsetTime .parse("15:30:30+07:00"); // apply range() method of OffsetTime class ValueRange result = offset.range(ChronoField.SECOND_OF_MINUTE); // print results System.out.println("Range in SECOND_OF_MINUTE: " + result); } } Output: Range in SECOND_OF_MINUTE: 0 - 59 References: https://docs.oracle.com/javase/10/docs/api/java/time/OffsetTime.html#range(java.time.temporal.TemporalField) Comment More infoAdvertise with us Next Article OffsetTime range() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Java-time package Java-OffsetTime Practice Tags : Java Similar Reads 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 OffsetTime until() Method in Java with Examples until() method of the OffsetTime class used to calculate the amount of time between two OffsetTime objects using TemporalUnit. The start and end points are this and the specified OffsetTime passed as a parameter. The result will be negative if the end is before the start. The calculation returns a w 2 min read OffsetTime query() method in Java with examples The Query() method of OffsetTime class in Java queries this time using the specified query. Syntax : public R query(TemporalQuery query) Parameter: This method accepts a single parameter query that specifies the query to be invoked and not null. Return Value: It returns the query result, null may be 1 min read OffsetTime of() method in Java with Examples The of(int hour, int minute, int second, int nanosecond, ZoneOffset offset) method of the OffsetTime class in Java is used to create an instance of OffsetTime from the passed values of hour, minute, second and nanosecond. In this method, we pass the value of hour, minute, second and nanosecond in in 2 min read OffsetTime with() Method in Java with Examples In OffsetTime class, there are two types of with() method depending upon the parameters passed to it. with(TemporalAdjuster adjuster) with(TemporalAdjuster adjuster) method of the OffsetTime class used to adjusted this OffsetTime using TemporalAdjuster and after adjustment returns the copy of adjust 3 min read Like