LocalDateTime equals(Object obj) example

Description

LocalDateTime equals(Object obj) checks if this date-time is equal to another date-time.

Syntax

equals has the following syntax.


public boolean equals(Object obj)

Example

The following example shows how to use equals.


import java.time.LocalDateTime;
// w  ww .jav  a  2s. co m
public class Main {
  public static void main(String[] args) {
    LocalDateTime a = LocalDateTime.now();
    
    System.out.println(a.equals(LocalDateTime.now()));
  }
}

The code above generates the following result.





















Home »
  Java Date Time »
    java.time Reference »




Clock
DayOfWeek
Duration
Instant
LocalDate
LocalDateTime
LocalTime
Month
MonthDay
OffsetDateTime
OffsetTime
Period
Year
YearMonth
ZonedDateTime
ZoneId
ZoneOffset