0
我喬達DateTime是否像這樣一個ArrayList:喬達日期時間數組排序數組按日期時間
List <DateTime> nextRemindersArray = new ArrayList<DateTime>();
nextRemindersArray.add(reminderOneDateTime);
nextRemindersArray.add(reminderTwoDateTime);
nextRemindersArray.add(reminderThreeDateTime);
我試圖以升序日期排序,但我有麻煩:
我用Google搜索並找到了這個網頁:
https://cmsoftwaretech.wordpress.com/2015/07/19/sort-date-with-timezone-format-using-joda-time/
我想它是這樣的:
nextRemindersArray.sort(nextRemindersArray);
但它給我的錯誤:
Error:(1496, 37) error: incompatible types: List<DateTime> cannot be converted to Comparator<? super DateTime>
我又試圖像這樣:
DateTimeComparator dateTimeComparator = DateTimeComparator.getInstance();
nextRemindersArray.sort(nextRemindersArray, dateTimeComparator);
而且這樣的:
nextRemindersArray.sort(nextRemindersArray, new DateTimeComparator());
但都有錯誤。
我嘗試了喬達時間手冊,並沒有太大的幫助。我如何對數組進行排序?
在此先感謝您的幫助
非常感謝你非常感謝! –