I am writing an app that needs to be quite accurate in dates and I wonder how can I compare LocalDate instances.. for now I was using something like:
LocalDate localdate1 = LocalDate().now();
LocalDate localdate2 = someService.getSomeDate();
localdate1.equals(localdate2);
But I noticed that my app is giving me some confusing results, and I think it is because of the date comparing.
I am thinking about obtaining the time from 1970' in long and compare those two, but I must be easier, I am sure of it
equals
say "Compares ... ensuring that the date is the same" . That sounds like the right thing in your case. – SulfamerazineisEqual()
. If both of your objects areLocalDate
, it will give you the same result asequals()
, which is what you want. If one happens to be a date in another calendar system (say, Hijri),equals()
will yieldfalse
, andisEqual()
will still correctly detect whether the two dates denote the same day. – Brassbound