package org.wreckage.gss; public class TimesheetLineByDateComparator implements java.util.Comparator { public int compare(TimesheetLine l1, TimesheetLine l2) { // OK, we know that all the lines that get to here have a date and a contact int dateComparison = l1.getDate().compareTo(l2.getDate()); if (dateComparison == 0) { if (l1.equals(l2)) return 0; else return l1.getId() < l2.getId() ? -1 : 1; } else return dateComparison < 0 ? -10 : 10; } }