Java Date Time - OffsetTime ofInstant(Instant instant, ZoneId zone) example








OffsetTime ofInstant(Instant instant, ZoneId zone) creates an instance of OffsetTime from an Instant and zone ID.

Syntax

ofInstant has the following syntax.

public static OffsetTime ofInstant(Instant instant,    ZoneId zone)

Example

The following example shows how to use ofInstant.

import java.time.Instant;
import java.time.OffsetTime;
import java.time.ZoneId;
/*  www .  j av a  2s  . c o m*/
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.ofInstant(Instant.now(),ZoneId.systemDefault());

    System.out.println(m);

  }
}

The code above generates the following result.