sort array list of special strings, by date

前端 未结 6 658
有刺的猬
有刺的猬 2021-01-25 10:33

I have an arrayList.

This is an arrayList of strings. The string contains a \"Date.toString\" in format of \"January 1, 1970, 00:00:00 GMT\" +

6条回答
  •  天命终不由人
    2021-01-25 11:04

    You could write a comparator that parses the dates and sorts them using date.compareTo(otherDate), but I'd suggest you store dates instead of Strings in the first place, making sorting much easier (Date implements Comparable.

    (If your input format is String, then convert the Strings at the time you add them to the list)

提交回复
热议问题