Java Date Time - Clock millis() example








Clock millis() gets the current millisecond instant of the clock. This returns the millisecond-based instant, measured from 1970-01-01T00:00Z (UTC).

Syntax

millis has the following syntax.

public long millis()

Example

The following example shows how to use millis.

import java.time.Clock;

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

The code above generates the following result.