Java Date Time - ZoneOffset equals(Object obj) example








ZoneOffset equals(Object obj) checks if this offset is equal to another offset.

Syntax

equals has the following syntax.

public boolean equals(Object obj)

Example

The following example shows how to use equals.

import java.time.ZoneOffset;

public class Main {
  public static void main(String[] args) {
    ZoneOffset z = ZoneOffset.UTC;
    System.out.println(z.equals(ZoneOffset.UTC));
  }
}

The code above generates the following result.