1

As per this question, I have found how to parse the Solr date, but I am still unable to compare it with Java date.

DateTimeFormatter parser2 = ISODateTimeFormat.dateTimeNoMillis();
    String jtdate = "2010-01-01T12:00:00+01:00";
    System.out.println(parser2.parseDateTime(jtdate));

Currently I have got date in this format : 2013-07-28T13:48:02Z and I need to apply compareTo() operator on this date with current date from Java.

Community
  • 1
  • 1
akshayb
  • 1,219
  • 2
  • 18
  • 44

1 Answers1

0

Assuming you do not care about the time, consider using DateTimeComparator.getDateOnlyInstance(), which is a Comparator that ignores the time fields when making the comparison, e.g.:

final DateTime a = parser2.parseDateTime(jtdate);
final Date b = new Date();

DateTimeComparator comparator = DateTimeComparator.getDateOnlyInstance();
comparator.compare(a, b);

Or,

comparator.compare(a, DateTime.now());
Jonathan
  • 20,053
  • 6
  • 63
  • 70