A date can be compared using a single operator, so you need a special function.
when dateTime is a DateTime() object
if((dateTime.toLocalDate()).equals(new LocalDate()))
when date is a java.util.date object
if((new DateTime(date).toLocalDate()).equals(new LocalDate()))
Which Joda-time class is best suited for this? LocalDate? DateTime?
Understanding that you need to know what LocalDate and DateTime are.
LocalDate() is an immutable datetime class representing a date without a time zone. Thus, you do not have part of the time.
DateTime() is a standard implementation of non-modifiable time datetime class. Having all the attributes of a Date, which includes date , time and timezone .
So, if you need to compare date and time better with dateTime , if you just need to check the date, you should use localDate , because datetime will generate false if the .equal operator, if the time including the second part is not the same for both objects .
Dileep
source share