import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
/**
* @ClassName:DateListSort
* @Description:对List中的日期进行排序
* @author:yaoshuai
* @data:2018/4/24
*/
public class DateSort {
public static ArrayList DateListSort(ArrayList dateList) throws Exception{
ComparatorDate c = new ComparatorDate();
Collections.sort(dateList, c);
return dateList;
}
}
class ComparatorDate implements Comparator {
public int compare(Object obj1, Object obj2) {
Date begin = (Date) obj1;
Date end = (Date) obj2;
if (begin.after(end)) {
return 1;
} else {
return -1;
}
}
}