标签:
private ListItem listItem;
listItem = new ListItem();
listItem.setReleasetime(releasetime);
List<ListItem> listItems = new ArrayList<ListItem>();
Collections.sort(listItems, new Comparator<ListItem>() {
@Override
public int compare(ListItem arg0, ListItem arg1) {
Date date1 = DateUtils.stringToDate(arg0.getReleasetime());
Date date2 = DateUtils.stringToDate(arg1.getReleasetime());
// 对日期字段进行升序,如果欲降序可采用after方法
if (date1.before(date2)) {
return 1;
}
return -1;
}
});
public class ListItem {
private String releasetime;
public String getReleasetime() {
return releasetime;
}
public void setReleasetime(String releasetime) {
this.releasetime = releasetime;
}
}
标签:
原文地址:http://www.cnblogs.com/xidada/p/4936913.html