java8 LocalDate 判断一年中的标准周末和工作日

    void myTest4() {
        LocalDate date = LocalDate.of(2020, 1, 1);
        while (date.getYear() < 2021){
            DayOfWeek week = date.getDayOfWeek();
            if(week == DayOfWeek.SATURDAY || week == DayOfWeek.SUNDAY) {
                System.out.println(date.toString()+"->周末");
            }else {
                System.out.println(date.toString()+"->工作日");
            }
            date = date.plusDays(1);
        }
    }

 

posted @ 2020-08-28 21:06  我是属车的  阅读(5072)  评论(0编辑  收藏  举报