You can create a custom List just to identify the dates that falls in the same week ex (I just used what @Jameson suggested in his answer, you can always write this a lot better):public List<WeekDay> getListOfWeeksFromListOfDates(List<Date> listOfDates) { List<WeekDay> listOfWeeks = new ArrayList<>(); WeekDay weekDay; for (Date date : listOfDates) { weekDay = new WeekDay(date, new SimpleDateFormat("w").format(date)); listOfWeeks.add(weekDay); } return listOfWeeks;}public class WeekDay { Date date; String weekIdentifier; public WeekDay(Date Date, String WeekIdentifier) { this.date = Date; this.weekIdentifier = WeekIdentifier; } public Date getDate() { return date; } public String getWeekIdentifier() { return weekIdentifier; }}然后您可以使用getListOfWeeksFromListOfDates(dates);列出具有Dates和Week编号的列表,该week编号可以用作比较日期的标识符,然后您可以添加具有相同Week号.. 希望您能得到我正在尝试传达的内容:)And you can use getListOfWeeksFromListOfDates(dates); to have a list with Dates and Week number, this week number can serve as an identifier to compare the dates and then you can add the activities for dates with same Week number.. Hope you are getting what i am trying to convey here :) 这篇关于如何在Java中将日期列表分组到对应的星期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-09 09:48