Clock tickSeconds(ZoneId zone) example
Description
Clock tickSeconds(ZoneId zone)
returns a clock for the
current instant ticking in whole seconds.
This clock will always have the nano-of-second field set to zero.
Syntax
tickSeconds
has the following syntax.
public static Clock tickSeconds(ZoneId zone)
Example
The following example shows how to use tickSeconds
.
import java.time.Clock;
import java.time.ZoneId;
/*from w w w. java2s . com*/
public class Main {
public static void main(String[] args) {
Clock clock = Clock.tickSeconds(ZoneId.systemDefault());
System.out.println(clock);
System.out.println(clock.instant());
}
}
The code above generates the following result.