Clock getZone() example

Description

Clock getZone() gets the time-zone used to create dates and times.

Syntax

getZone has the following syntax.


public abstract ZoneId getZone()

Example

The following example shows how to use getZone.


import java.time.Clock;
/*w w  w. ja  v a 2s  .  c  om*/
public class Main {
  public static void main(String[] args) {
    Clock clock = Clock.systemDefaultZone();
    
    System.out.println(clock.getZone());
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset