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.
ublic 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:
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.