LocalDate获取下周几的日期

public static LocalDate byWeek(int dictionaryWeek) {
        int day = 0;
        int value = LocalDate.now().getDayOfWeek().getValue();
        if (dictionaryWeek == value) {
            day = 7;
        }
        if (value < dictionaryWeek) {
            day = dictionaryWeek - value;
        }
        if (value > dictionaryWeek) {
            day = 7 - (value - dictionaryWeek);
        }
        return LocalDate.now().plusDays(day);
    }

    public static void main(String[] args) {
        LocalDate localDate = byWeek(5);
        System.out.println("下周五是:"+localDate);
    }

 

你可能感兴趣的:(java后台)