//DateComparator.java //example of a class to compare user-defined objects so they can be used in a Collection for sorting import java.util.*; //**comparator for specifying how to compare Dates. //***your class implementing Comparator interface which requires the compare method public class DateComparator implements Comparator { //***must be this signature. Note the two parameters are Objects. //***must return 0 if equal, positive if a>b, negative if a d2.getYear()) return 1; else if (d1.getYear() < d2.getYear()) return -1; else if (d1.getMonth() > d2.getMonth()) return 1; else if (d1.getMonth() < d2.getMonth()) return -1; else if (d1.getDay() > d2.getDay()) return 1; else if (d1.getDay() < d2.getDay()) return -1; else return 0; //same dates } }