The equals() method of LocalDateTime class in Java checks if this date-time is equal to another date-time. This other date-time is passed as the parameter. This method returns a boolean value showing the same.
public boolean equals(Object date2)
Parameter: This method accepts a parameter date2 which checks if this date-time is equal to another date-time.
Returns: The function returns a boolean value if this is equal to the other date-time.
Below programs illustrate the LocalDateTime.equals() method:
Date 1: 2018-11-03T12:45:30 Date 2: 2018-11-03T12:45:30 Is Date 1 equal to Date 2: true
Date 1: 1998-01-05T06:20:10 Date 2: 2018-11-03T12:45:30 Is Date 1 equal to Date 2: false
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready.