diff --git a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java index c47e660..018c106 100644 --- a/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java +++ b/src/main/java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java @@ -568,6 +568,12 @@ public class GoodsServiceImpl implements GoodsService { try { // 委托开始时间 Date wtStart = sdf.parse(cstart); + // 判断周几 + calendar.setTime(wtStart); + int wkday = calendar.get(Calendar.DAY_OF_WEEK); + //周末顺延 + // notice:在节假日调休时候,会有变动 + day=wkday>5?(wkday-5+1):0; // 委托终止时间 Date wtEnd = DateUtils.daysAgoOrAfter(wtStart, day); // 统计该时间段内的节假日 diff --git a/src/test/java/cn/chjyj/szwh/NewTest.java b/src/test/java/cn/chjyj/szwh/NewTest.java index 5731fcb..cef262d 100644 --- a/src/test/java/cn/chjyj/szwh/NewTest.java +++ b/src/test/java/cn/chjyj/szwh/NewTest.java @@ -56,6 +56,12 @@ public class NewTest { int days = festivalsMapper.countDayBetweenDays(date,afdate0,iyear); Date afdate = DateUtils.daysAgoOrAfter(afdate0,days); System.out.println(afdate+"以前的节假日天数:"+days); + //判断当前时间是否为周末 + calendar.setTime(date); + long weekDate =calendar.get(Calendar.DAY_OF_WEEK); + + //Date weekDate = calendar.getTime(); + System.out.println("周几:"+weekDate); //转为localDateTime LocalDateTime aflocal = DateUtils.convertDateToLocalDateTime(afdate);