From 49087c8907e5b5bb8d19fe5f4fee1ea8fd927739 Mon Sep 17 00:00:00 2001 From: xyiege Date: Wed, 28 Sep 2022 02:18:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=91=A8=E6=9C=AB=E9=A1=BA=E5=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/chjyj/szwh/service/impl/GoodsServiceImpl.java | 6 ++++++ src/test/java/cn/chjyj/szwh/NewTest.java | 6 ++++++ 2 files changed, 12 insertions(+) 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);