问题
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