LocalDate
in Java has two similar methods equals
and isEqual
.
What's the difference between them? When do they output different results?
LocalDate.equals
, like most other equals
method implementations, will always return false if you pass it something other than a LocalDate
, even if they represent the same day:
System.out.println(LocalDate.now().equals(HijrahDate.now())); // false
ChronoLocalDate.isEqual
compares whether the two dates are the same day, i.e. the same point on the local time line:
System.out.println(LocalDate.now().isEqual(HijrahDate.now())); // true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With