/**
* 按照指定字段排序
* @param dateSourceList
* @return 排序重组后的数据
*/
private List<Bean> sortList(List<Bean> dateSourceList) {
List<Bean> newBean = new ArrayList<>();
for (int i = 0; i < dateSourceList.size(); i++) {
Bean maxBean = dateSourceList.get(i);
for (int j = newBean.size(); j < dateSourceList.size(); j++) {
if (!dateSourceList.get(i).getId().equals(dateSourceList.get(j).getId())) {
Bean bean2 = dateSourceList.get(j);
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date or1 = sf.parse(maxBean.getStr("MIND_TIME"));
Date or2 = sf.parse(bean2.getStr("MIND_TIME"));
if (or2.after(or1)) {
// 如果比他大,则替换为最大
maxBean = bean2;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
}
// 将最大的添加到list中
newBean.add(maxBean);
}
return newBean;
}
希望大家都有所得。