sort array list of special strings, by date

前端 未结 6 674
有刺的猬
有刺的猬 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 10:57

    Write your own comparator. Then use Collections.sort(arrayList, myComparator);

    Comparator myComparator = new Comparator() {
    
     int compareTo(String string1, String string2) {
         ......
     }
    
     boolean equals(String str1) {
        ......
     }
    
    }
    

提交回复
热议问题