Does Joda-Time have a method called isToday
datetime, java, jodatime
Solution
The date can be compared by single statement so why you need a special function.
when `dateTime`is an object of `DateTime()`
if((dateTime.toLocalDate()).equals(new LocalDate()))
when `date` is an object of `java.util.date`
if((new DateTime(date).toLocalDate()).equals(new LocalDate()))
What Joda-time class is better suited for this? LocalDate? DateTime?
The understanding that you need to know what is LocalDate and DateTime.
`LocalDate()` is an immutable datetime class representing a date without a time zone. So is not having a time part.
`DateTime()` is the standard implementation of an unmodifiable datetime class. Its having all the attributes of the Date, which includes `date`, `time` and `timezone`.
So if you need to compare both the date and time better go with `datetime`, if you just need to check the date you must use `localDate` because the datetime will produce a `false` if an `.equal` operator is used, unless the time including the seconds part are same for both the objects.
Problem
I need to check if a given timestamp is today. I am using Joda-Time. Is there a method or a simple way to check this? What Joda-Time class is better suited for this? LocalDate? DateTime?