Easy learning with example program codes

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

Method Description
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.codesjava;
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); 


Posted in Date   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki