Java Date Time - OffsetTime getOffset() example








OffsetTime getOffset() gets the zone offset, such as '+01:00'.

This is the offset of the local time from UTC/Greenwich.

Syntax

getOffset has the following syntax.

public ZoneOffset getOffset()

Example

The following example shows how to use getOffset.

import java.time.OffsetTime;
import java.time.ZoneOffset;
//www  .j  a  v a  2s  .c  o  m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now();
    ZoneOffset z = m.getOffset();
    System.out.println(z);

  }
}

The code above generates the following result.