Java Date Time - Clock instant() example








Clock instant() gets the current instant of the clock representing the current instant as defined by the clock.

Syntax

instant has the following syntax.

public abstract Instant instant()

Example

The following example shows how to use instant.

import java.time.Clock;

public class Main {
  public static void main(String[] args) {
    Clock clock = Clock.systemUTC();
    System.out.println(clock.instant());
  }
}

The code above generates the following result.