Clock millis() example

Description

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;
//from  ww  w.j  ava  2  s. co  m
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.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset