try { if (o1.getSentDate() == null) { return 1; } else if (o2.getSentDate() == null) { return -1; } else return o2.getSentDate().compareTo(o1.getSentDate()); } catch (Exception e) { return 0; }