Java Date Time - ZoneOffset get(TemporalField field) example








ZoneOffset get(TemporalField field) gets the value of the specified field from this offset as an int.

Syntax

get has the following syntax.

public int get(TemporalField field)

Example

The following example shows how to use get.

import java.time.ZoneOffset;
import java.time.temporal.ChronoField;
/*from w  w  w .  j av a 2  s  . c  o  m*/
public class Main {
  public static void main(String[] args) {
    ZoneOffset z = ZoneOffset.UTC;
    int t = z.get(ChronoField.OFFSET_SECONDS);
    System.out.println(t);
  }
}

The code above generates the following result.