I have a below program to compare two dates.
I get timestamps that are date1 and currentTimestamp, here i need to compare only dates not the time values.But below program always returns -1.(value)
timestamp date1 = "2017-01-20 14:51:30.091" // i get this from service call in this format
SimpleDateFormat dateFormat = new SimpleDateFormat(DEFAULT_TIMESTAMP_FORMAT);
Calendar calendar = Calendar.getInstance();
String formattedDate = dateFormat.format(calendar.getTime());
java.util.Date currentDate = dateFormat.parse(formattedDate);
java.sql.Timestamp currentTimestamp = new java.sql.Timestamp(currentDate.getTime());
int value = DateTimeComparator.getDateOnlyInstance().compare(date1 , currentTimestamp );
How to compare only dates regardless of time. Please help me on this.
UPDATED:
i changed to below code
timestamp date1 = "2017-01-20 14:51:30.091" // i get this from service call in this format
LocalDate localDate = new LocalDate();
int value = DateTimeComparator.getDateOnlyInstance().compare(date1 , localDate );
this gives me error saying "java.lang.IllegalArgumentException: No instant converter found for type: org.joda.time.LocalDate"