我有一个时间戳列表(长),我必须根据时间或列表添加排序列表。如何对时间戳列表进行排序?
我已经尝试过,但其现在的工作。
Collections.sort(vehicles, new Comparator<VehicleListModel.Vehicle>() {
@Override
public int compare(VehicleListModel.Vehicle o1, VehicleListModel.Vehicle o2) {
try {
DateFormat format = new SimpleDateFormat("MM-dd-yyyy hh:mm:ss");
return format.parse(o1.getCreated()).compareTo(format.parse(o2.getCreated()));
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
});
customerListAdapter.notifyDataSetChanged();
它不工作,然后我试图 this但这Date(timeStamp)
已被弃用
请帮助
***我已经尝试过,但现在正在努力工作***这不足以帮助我们! **如何**不起作用? –
这是什么字符串:getCreated()? –
getCreated()将返回时间戳添加到服务现在我必须根据时间戳进行排序 –