I have to compare two dates where first date is in Calendar format and other in string(DD-MMM-yyyy) format. So I want to convert one of the Calendar dates into String and use compareTo method.
I have tried using :
SimpleDateFormat formatter=new SimpleDateFormat("DD-MMM-yyyy");
String currentDate=formatter.format(view.getSelectedDay());
Assuming
view.getSelectedDay()returns aCalendar, you may simply want:(So that you have a
Datereference to pass in toformat.)If that’s not the problem, please give more information. I suspect you also want “dd” instead of “DD” by the way. “DD” is the day of year whereas “dd” is the day of month, as per the
SimpleDateFormatdocumentation.