ZoneOffset ofOffset() method in Java with Examples Last Updated : 02 Feb, 2022 Summarize Comments Improve Suggest changes Share Like Article Like Report The ofOffset() method of the ZoneOffset class used to obtain an instance of ZoneOffset wrapping an offset.If the prefix passed in this method is "GMT", "UTC", or "UT" a ZoneOffset with the prefix then the non-zero offset is returned and If the prefix is empty "" then the ZoneOffset is returned.Syntax: public static ZoneId ofOffset(String prefix, ZoneOffset offset) Parameters: This method accepts two parameters prefix and offset where prefix represents the time-zone ID and offset represents the offset.Return value: This method returns the zoneId.Exception: This method throws an IllegalArgumentException if the prefix is not one of "GMT", "UTC", or "UT", or "".Below programs illustrate the ofOffset() method:Program 1: Java // Java program to demonstrate // ZoneOffset.ofOffset() method import java.time.*; public class GFG { public static void main(String[] args) { // create ZoneId object ZoneId zoneId = ZoneId.ofOffset("UTC", ZoneOffset.UTC); // Print the ZoneOffset System.out.println("ZoneOffset: " + zoneId); } } Output: ZoneOffset: UTC Program 2: Java // Java program to demonstrate // ZoneOffset.ofOffset() method import java.time.*; public class GFG { public static void main(String[] args) { // create ZoneId object ZoneId zoneId = ZoneId.ofOffset("GMT", ZoneOffset.MAX); System.out.println("ZoneOffset: " + zoneId); } } Output: ZoneOffset: GMT+18:00 Reference: Oracle Doc Comment More infoAdvertise with us Next Article ZoneId ofOffset() method in Java with Examples C code_r Follow Improve Article Tags : Java Java-Functions Java-time package Java-ZoneOffset Practice Tags : Java Similar Reads ZoneOffset of(String) method in Java with Examples The of(String) method of ZoneOffset Class in java.time package is used to obtain an instance of ZoneOffset using the offsetId passed as the parameter. This method takes the offsetId as parameter in the form of String and converts it into the ZoneOffset. The ID of the returned offset will be normaliz 2 min read ZoneId ofOffset() method in Java with Examples The ofOffset() method of the ZoneId class used to obtain an instance of ZoneId wrapping an offset.If the prefix passed in this method is "GMT", "UTC", or "UT" a ZoneId with the prefix then the non-zero offset is returned and If the prefix is empty "" then the ZoneOffset is returned.Syntax: public st 1 min read ZoneOffset toString() method in Java with Examples The toString() method of ZoneOffset Class in java.time package is used to obtain String representation of this instance of ZoneOffset. This method does not takes any parameter and returns an String value. which is the String representation. Syntax: public static String toString() Parameters: This me 1 min read ZoneOffset ofHours(int) method in Java with Examples The ofHours(int) method of ZoneOffset Class in java.time package is used to obtain an instance of ZoneOffset using the offset in hours passed as the parameter. This method takes the hours as parameter in the form of int and converts it into the ZoneOffset. The maximum supported range is from +18:00 2 min read ZoneOffset equal(Object) method in Java with Examples The equals(Object) method of ZoneOffset Class in java.time package is used to check whether the another instance of ZoneOffset passed as the parameter to this ZoneOffset instance, is equal or not. This method returns a boolean value stating the same. Syntax: public boolean equals(Object object) Para 2 min read ZoneOffset ofTotalSeconds(int) method in Java with Examples The ofTotalSeconds(int) method of ZoneOffset Class in java.time package is used to obtain an instance of ZoneOffset using the offset in totalSeconds passed as the parameter. This method takes the totalSeconds as parameter in the form of int and converts it into the ZoneOffset. Syntax: public static 2 min read Like