Java Date Time - OffsetTime of(LocalTime time, ZoneOffset offset) example








OffsetTime of(LocalTime time, ZoneOffset offset) creates an instance of OffsetTime from a local time and an offset.

Syntax

of has the following syntax.

public static OffsetTime of(LocalTime time,   ZoneOffset offset)

Example

The following example shows how to use of.

import java.time.LocalTime;
import java.time.OffsetTime;
import java.time.ZoneOffset;
//  w w  w .ja v a 2 s. co m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.of(LocalTime.now(),ZoneOffset.UTC);

    System.out.println(m);

  }
}

The code above generates the following result.