Java Date Time - Clock equals(Object obj) example








Clock equals(Object obj) checks if this clock is equal to another clock.

Syntax

equals has the following syntax.

public boolean equals(Object obj)

Example

The following example shows how to use equals.

import java.time.Clock;

public class Main {
  public static void main(String[] args) {
    Clock clock = Clock.systemUTC();
    Clock clock1 = Clock.systemDefaultZone();
    System.out.println(clock.equals(clock1));
  }
}

The code above generates the following result.