Java Date Time - LocalDate equals(Object obj) example








LocalDate equals(Object obj) checks if this date is equal to another date.

Syntax

equals has the following syntax.

public boolean equals(Object obj)

Example

The following example shows how to use equals.

import java.time.LocalDate;
//from w w  w.  j av  a 2  s .  com
public class Main {
  public static void main(String[] args) {
    LocalDate l = LocalDate.now();
    
    System.out.println(l.equals(LocalDate.now()));
 
  }
}

The code above generates the following result.