Java Date Time - ZoneId equals(Object obj) example








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;

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.