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