更新时间: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)