日历制作
//使用jdk1.8
public List<DayInfo> getDayInfoList(int year, int month) throws Exception {
if (year <= 0 || month <= 0 || month > 12) {throw new IllegalArgumentException("無效的參數。");}LocalDate localDate = LocalDate.of(year, month, 1);int weekday = localDate.getDayOfWeek().ordinal() + 1;String startDay = localDate.minusDays(weekday - 1).format(DateTimeFormatter.ofPattern("yyyyMMdd"));localDate = LocalDate.of(year, month, localDate.lengthOfMonth());weekday = localDate.getDayOfWeek().ordinal() + 1;localDate = localDate.plusDays(7 - weekday);String endDay = localDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));return getDayInfoList(startDay, endDay); //返回出差 }//getDayInfo這個方法可以寫個起始日期和結束日期總結
- 上一篇: 新一配:区块链迎最强风口 可当钱用的数字
- 下一篇: Vite 配置 cdn 加载资源