How to Sort Date in descending order From Arraylist Date in android?

前端 未结 6 1624
名媛妹妹
名媛妹妹 2020-12-15 21:04

I have an ArrayList which stores Dates and I sorted them in descending order. Now I want to display them in a ListView. This is what I

6条回答
  •  时光说笑
    2020-12-15 21:28

    Date is Comparable so just create list of List and sort it using Collections.sort(). And use Collections.reverseOrder() to get comparator in reverse ordering.

    From Java Doc

    Returns a comparator that imposes the reverse ordering of the specified comparator. If the specified comparator is null, this method is equivalent to reverseOrder() (in other words, it returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface).

提交回复
热议问题