Java获取指定日期的下一个周五

获取一个指定日期的下一个周一、周四和周五

            LocalDate localDateSunday = LocalDate.parse(takeDate).with(DayOfWeek.of(1)).plusDays(7);
            LocalDate localDateThursday = LocalDate.parse(takeDate).with(DayOfWeek.of(4)).plusDays(7);
            LocalDate localDateFriday = LocalDate.parse(takeDate).with(DayOfWeek.of(5)).plusDays(7);
            ZonedDateTime zonedDateTime = localDateSunday.atStartOfDay(ZoneId.systemDefault());
            ZonedDateTime zonedDateTimeThursday = localDateThursday.atStartOfDay(ZoneId.systemDefault());
            ZonedDateTime zonedDateTimeFriday = localDateFriday.atStartOfDay(ZoneId.systemDefault());
            //周一
            Date dateSunday = Date.from(zonedDateTime.toInstant());
            //周四
            Date dateThursday = Date.from(zonedDateTimeThursday.toInstant());
            //周五
            Date dateFriday = Date.from(zonedDateTimeFriday.toInstant());

你可能感兴趣的:(JavaSE,java)