Java Date Time - ZoneId ofOffset(String prefix, ZoneOffset offset) example








ZoneId ofOffset(String prefix, ZoneOffset offset) creates an instance of ZoneId wrapping an offset.

Syntax

ofOffset has the following syntax.

public static ZoneId ofOffset(String prefix,   ZoneOffset offset)

Example

The following example shows how to use ofOffset.

import java.time.ZoneId;
import java.time.ZoneOffset;
/*w ww . ja  va  2  s.  c  o  m*/
public class Main {
  public static void main(String[] args) {
    ZoneId z = ZoneId.ofOffset("UTC",ZoneOffset.UTC);
    
    System.out.println(z);
  } 
}

The code above generates the following result.