Java Date Time - OffsetTime now(Clock clock) example








OffsetTime now(Clock clock) creates the current time from the specified clock.

Syntax

now has the following syntax.

public static OffsetTime now(Clock clock)

Example

The following example shows how to use now.

import java.time.Clock;
import java.time.OffsetTime;
//w  w w .  j a  v a2  s  .  c o  m
public class Main {
  public static void main(String[] args) {
    OffsetTime m = OffsetTime.now(Clock.systemUTC());

    System.out.println(m);

  }
}

The code above generates the following result.