如何在Android或Java中对从当前日期到旧日期的日期进行排序? [英] How to sort the dates from current to old date in Android or Java?
本文介绍了如何在Android或Java中对从当前日期到旧日期的日期进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要用户定义的功能,可以将日期从当前时间排序到旧时间。
I am in a need of function, user defined, which could sort the dates from current time to old time.
我有10个日期列表我想从上次最近的日期开始对这些日期进行排序。
I'm having list of 10 dates which I want to sort these dates starting from last recent date.
目前我有一个逻辑,如果我们可以用毫秒来隐藏日期强>然后将它与当前毫秒相比较,最小毫秒将是最近的日期。
即,
Currently I have a logic, in which if we can covert the date in milli-second then comparing it with current-milli-seconds and the least milli-second will be the recent date. That is,
CURRENT_MILLI_SECOND - A_DATE_CONVERTED_TO_MILLI_SECONDS = MILLI-SECONDS
如果有人可以帮我解决这个逻辑或任何其他逻辑,请建议我...... !!!
Please suggest me if anyone can help me in this logic or any other logics...!!!
这是我从服务器获得的结构:
This is the formate which I am getting from server:
Thu Dec 27 11:02:43 GMT+05:30 2012
推荐答案
Collections.sort(dateList, new Comparator<Date>(){
public int compare(Date date1, Date date2){
return date1.after(date2);
}
});
这篇关于如何在Android或Java中对从当前日期到旧日期的日期进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文