且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

特殊字符串数组排序列表,按日期

更新时间:2023-01-30 09:47:56

您的可能的写分析的日期,并使用 date.compareTo(otherDate)将它们排序,比较,但我建议你存储日期而不是字符串摆在首位,使排序更容易(日期农具可比<日期方式>

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<Date>.

(如果你的输入格式为:字符串,然后转换字符串的时候将它们添加到列表)

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