Java Date Time - ZoneOffset ofHours(int hours) example








ZoneOffset ofHours(int hours) creates an instance of ZoneOffset using an offset in hours.

Syntax

ofHours has the following syntax.

public static ZoneOffset ofHours(int hours)

Example

The following example shows how to use ofHours.

import java.time.ZoneOffset;

public class Main {
  public static void main(String[] args) {
    ZoneOffset t = ZoneOffset.ofHours(1);
    System.out.println(t);
  }
}

The code above generates the following result.