Java 8 ZoneOffset class

The java.time.ZoneOffset class is used to represent the fixed zone offset from UTC time zone.
ZoneOffset class constants:

  • MAX: maximum supported zone offsets.
  • MIN: minimum supported zone offsets.
  • UTC: time zone offset constant for UTC.

Java ZoneOffset class methods

Temporal adjustInto(Temporal temporal)It is used to adjust the specified temporal object to have the same offset as this object.
int get(TemporalField field)It is used to get the value of the specified field from this offset as an int.
boolean isSupported(TemporalField field)It is used to check if the specified field is supported.
static ZoneOffset of(String offsetId)It is used to obtain an instance of ZoneOffset using the ID.
static ZoneOffset ofHours(int hours)It is used to obtain an instance of ZoneOffset using an offset in hours.
static ZoneOffset ofHoursMinutes(int hours, int minutes)It is used to obtain an instance of ZoneOffset using an offset in hours and minutes.
ValueRange range(TemporalField field)It is used to get the range of valid values


package com.w3spoint;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
public class TestExample {
	public static void main(String args[]){
	    ZoneOffset zone1 = ZoneOffset.UTC;  
	    Temporal temp = zone1.adjustInto(;  
	    //ofHours() method
	    ZoneOffset zone2 = ZoneOffset.ofHours(5);  
	    //ofHoursMinutes() method
	    ZoneOffset zone3 = ZoneOffset.ofHoursMinutes(5,30); 


Content Protection by
Please Share