Java Date Time - LocalTime equals(Object obj) example








LocalTime equals(Object obj) checks if this time is equal to another time.

Syntax

equals has the following syntax.

public boolean equals(Object obj)

Example

The following example shows how to use equals.

import java.time.LocalTime;

public class Main {
  public static void main(String[] args) {
    LocalTime l = LocalTime.now();

    System.out.println(l.equals(LocalTime.NOON));
  }
}

The code above generates the following result.