DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); LocalDate startLocalDate = LocalDate.parse("2021-01-01", formatter); LocalDate endLocalDate = LocalDate.parse("2021-01-17", formatter); List<String> dateList = new ArrayList<>(); while (startLocalDate.isBefore(endLocalDate)) { int value = startLocalDate.getDayOfWeek().getValue(); startLocalDate = startLocalDate.plusDays(1); if (value == 6 || value == 7) { continue; } dateList.add(startLocalDate.minusDays(1).format(formatter)); }
两个日期跳过周六周日的全部日期
最新推荐文章于 2021-04-26 16:38:36 发布