Instant now(Clock clock) example
Description
Instant now(Clock clock)
gets the current instant from the specified clock.
Syntax
now
has the following syntax.
public static Instant now(Clock clock)
Example
The following example shows how to use now
.
import java.time.Clock;
import java.time.Instant;
//from w w w . ja v a 2 s.c o m
public class Main {
public static void main(String[] args) {
Instant instant = Instant.now(Clock.systemDefaultZone());
System.out.println(instant.getEpochSecond());
}
}
The code above generates the following result.