java.time.Clock.tickSeconds(ZoneId zone) method is a static method of Clock class which returns a clock that returns the current instant ticking in whole Seconds using best available system clock and zone of instant is same as the instant passed as a parameter.
The returned clock is also immutable, thread-safe and Serializable and this method is equivalent to tick(system(zone), Duration.ofSeconds(1)).
public static Clock tickSeconds(ZoneId zone)
Parameters: This method takes a mandatory parameter zone which is the time-zone to use to round off instant of a clock in the whole Second.
Return Value: This method returns a clock that returns the current instant ticking in whole Second with zone same as zone passed as parameter.
Code: ZoneId zoneId = ZoneId.of("Asia/Calcutta"); Clock clock = Clock.tickSeconds(zoneId); System.out.println(clock.instant()); Output: 2018-08-21T20:22:32Z Expalnation:: method tickSeconds() returns the instant which tick in a whole Second means nanosecond field is zero.
Below programs illustrates tickSeconds() method of java.time.Clock class:
Program 1; When Clock is created with Zone kolkata and printing instant of clock ticking in whole Second.
Program 2: Print the date and Time of clock with zone Europe/Paris and clock ticks per whole Second.
Date and Time :2018-08-22T13:27:41+02:00[Europe/Paris]
- Clock systemDefaultZone() Method in Java with Examples
- Java 8 Clock offset() method with Examples
- Clock systemUTC() Method in Java with Examples
- Clock system() Method in Java with Examples
- Java 8 Clock equals() Method with Examples
- Java 8 Clock fixed() method with Examples
- Java 8 Clock millis() Method with Examples
- Clock tick() Method in Java with Examples
- Java 8 Clock instant() method with Examples
- Java 8 Clock hashCode() method with Examples
- Java 8 Clock getZone() method with Examples
- Java Clock withZone() method in Java with Examples
- Java Clock tickMinutes() method in Java with Examples
- Android | How to display Analog clock and Digital clock
- Java Applet | How to display a Digital Clock
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.