ZoneId equals(Object obj) example

Description

ZoneId equals(Object obj) checks if this time-zone ID is equal to another time-zone ID. The comparison is based on the ID.

Syntax

equals has the following syntax.


public boolean equals(Object obj)

Example

The following example shows how to use equals.


import java.time.ZoneId;
/*from w  w  w  .java 2s.  c  om*/
public class Main {
  public static void main(String[] args) {
    ZoneId z = ZoneId.systemDefault();
    System.out.println(z.equals(ZoneId.systemDefault()));
  } 
}

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