Java Date Time - ZoneOffset ofTotalSeconds(int totalSeconds) example








ZoneOffset ofTotalSeconds(int totalSeconds) creates an instance of ZoneOffset specifying the total offset in seconds.

The offset must be in the range -18:00 to +18:00, which corresponds to -64800 to +64800.

Syntax

ofTotalSeconds has the following syntax.

public static ZoneOffset ofTotalSeconds(int totalSeconds)

Example

The following example shows how to use ofTotalSeconds.

import java.time.ZoneOffset;

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

The code above generates the following result.