Sorting list having itemBean by date?

寵の児 提交于 2019-12-25 01:33:53

问题


how to sort a list by date in android

List<ItemBean> listIB = new ArrayList<ItemBean>();
for(int i=0; i<DispLibActivity.itemListVect.size(); i++)
{
    listIB.add(DispLibActivity.itemListVect.get(i));
}

ItemBean class have a member date

public class ItemBean implements Parcelable{
    String item_id, item_title, image_url, link_url, description, publish_date,
        in_app_date, sub_section_id, type, duration, orig_url, sync;
    ....
    ....
}

I want to sort list "listIB" with its member "publish_date"


回答1:


use SimpleDateFormat to parse the date string, get the Date object and confront the time in milliseconds in a comparator.



来源:https://stackoverflow.com/questions/9912574/sorting-list-having-itembean-by-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!