java8 根据年份和周数 获取周一和周日日期

localDate.with(weekFields.dayOfWeek(), 7L);
1L是周一 7L是周日

        WeekFields weekFields= WeekFields.ISO;
        LocalDate now = LocalDate.now();
        //输入你想要的年份和周数
        LocalDate localDate = now.withYear(2021).with(weekFields.weekOfYear(),1);
        //周一
        LocalDate localDate1  = localDate.with(weekFields.dayOfWeek(), 1L);
        //周日
        LocalDate localDate2  = localDate.with(weekFields.dayOfWeek(), 7L);

你可能感兴趣的:(java8 根据年份和周数 获取周一和周日日期)