Java Date Time - OffsetTime from(TemporalAccessor temporal) example








OffsetTime from(TemporalAccessor temporal) creates an instance of OffsetTime from a temporal object.

Syntax

from has the following syntax.

public static OffsetTime from(TemporalAccessor temporal)

Example

The following example shows how to use from.

import java.time.OffsetTime;
import java.time.ZonedDateTime;
//from  www .  j a v  a2s.  c o m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.from(ZonedDateTime.now());

    System.out.println(m);

  }
}

The code above generates the following result.