How to Sort an Arraylist of Date in ascending and descending order which is in String format

后端 未结 6 1720
轻奢々
轻奢々 2020-12-17 02:36

I have arrayLists of Dates which is in String format then how can I sort this arraylists,

ArrayList aryBeginDate;
ArrayList aryDu         


        
6条回答
  •  既然无缘
    2020-12-17 03:17

    Very Simple Answer:For Ascending just call this method:

    Collections.sort(mArrayList, new OutcomeAscComparator());
    public class OutcomeAscComparator implements Comparator
        {
            public int compare(Select left, Select right) {
                return right.getOutcome().compareTo(left.getOutcome());
            }
        }
    

    Please dont forget to refresh your list view IF you want your list to be AScending and Descending

                    mListView.invalidateViews();
    
                    mAdapter.notifyDataSetChanged();
    

提交回复
热议问题