获取哪一年 周一的所有日期
WeekFields weekFields= WeekFields.ISO; int num = LocalDate.of(2020, 12, 31).get(weekFields.weekOfWeekBasedYear()); //一年最后一天日期的LocalDate,如果该天获得的周数为1或52,那么该年就只有52周,否则就是53周 num = (num == 1 || num==52) ? 52 : num; System.out.println("共有多少个周"+num); LocalDate now = LocalDate.now(); List timeSum=new ArrayList<>(); for (int i = 1; i <=num; i++) { //输入你想要的年份和周数 LocalDate localDate = now.withYear(2020).with(weekFields.weekOfYear(),i); //周一 LocalDate localDate1 = localDate.with(weekFields.dayOfWeek(), 1L); timeSum.add(localDate1); //周日 LocalDate localDate2 = localDate.with(weekFields.dayOfWeek(), 7L); } System.out.println(timeSum);