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.
tickSeconds
has the following syntax.
public static Clock tickSeconds(ZoneId zone)
The following example shows how to use tickSeconds
.
import java.time.Clock; import java.time.ZoneId; //from w w w . j a v a2 s .c om 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.