//返回数据按照出生日期降序排 (我比较懒,方法头就不写了~~)
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Collections.sort(list, new Comparator<AppView>(){
@Override
public int compare(AppView arg0, AppView arg1) {
int mark = 1;
try {
Date date0 = sdf.parse(arg0.getTime().replaceAll("/", "-"));
Date date1 = sdf.parse(arg1.getTime().replaceAll("/", "-"));
if(date0.getTime() > date1.getTime()){
mark = -1;
}
if(arg0.getTime().equals(arg1.getTime())){
mark = 0;
}
} catch (Exception e) {
System.out.println("==========================日期转换异常==========================");
e.printStackTrace();
}
return mark;
}
});
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Collections.sort(list, new Comparator<AppView>(){
@Override
public int compare(AppView arg0, AppView arg1) {
int mark = 1;
try {
Date date0 = sdf.parse(arg0.getTime().replaceAll("/", "-"));
Date date1 = sdf.parse(arg1.getTime().replaceAll("/", "-"));
if(date0.getTime() > date1.getTime()){
mark = -1;
}
if(arg0.getTime().equals(arg1.getTime())){
mark = 0;
}
} catch (Exception e) {
System.out.println("==========================日期转换异常==========================");
e.printStackTrace();
}
return mark;
}
});