Java Clock class is part of Date Time API, java.time.Clock, of Java. The Java Date Time API was added from Java version 8.
getZone() method of Clock class returns the time-zone used to create dates and times of Clock class. Every Clock class needs a Time Zone for obtaining the current instant of time and convert that instance to a date or time. So this method returns the time-zone used for this process.
public abstract ZoneId getZone()
Returns Value: This Method returns the time-zone used to create Clock class.
Input:: a clock class Object e.g Clock.systemUTC() Output:: TimeZone e.g. Z Explanation:: when Clock.getZone() is called, then it returns a Time Zone used in Class Object
Below programs illustrates getZone() method of java.time.Clock class:
Program 1: Get the TimeZone of the Clock obejct, created with systemDefaultZone, using getZone()
ZoneId for class SystemClock[Etc/UTC] is Etc/UTC
Program 2:Get TimeZone of Clock object, with Zone “Asia/calcutta”, using getZone().
ZoneId for clock is Asia/Calcutta
- ChronoZonedDateTime getZone() method in Java with Examples
- ZonedDateTime getZone() method in Java with Examples
- Java 8 Clock offset() method with Examples
- Clock system() Method in Java with Examples
- Clock systemDefaultZone() Method in Java with Examples
- Java 8 Clock equals() Method with Examples
- Clock systemUTC() Method in Java with Examples
- Clock tick() Method in Java with Examples
- Java 8 Clock millis() Method with Examples
- Java 8 Clock hashCode() method with Examples
- Java 8 Clock fixed() method with Examples
- Java 8 Clock instant() method with Examples
- Clock tickSeconds() method in Java with Examples
- Java Clock withZone() method in Java with Examples
- Java Clock tickMinutes() method in Java with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.
Improved By : Kirti_Mangal