I have two date strings say , "2011-04-29" and "2011-01-28" , and i want to compare them using Joda Time. Is there a way to do that ?. An example would be really appreciated.
Thanks
First you need to parse them. Use DateTimeFormat
:
DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyy-MM-dd");
DateTime dateTime1 = fmt.parseDateTime(string1);
Then use DateTime.isBefore(..)
to compare them:
if (dateTime1.isBefore(dateTime2))
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