From 8248a9ecee46ddad3f2d91415401bd4751581cdb Mon Sep 17 00:00:00 2001 From: yang_shj <1069818635@QQ.com> Date: Tue, 5 Mar 2024 09:30:21 +0800 Subject: [PATCH] =?UTF-8?q?#=E5=8F=91=E7=94=B5=E9=87=8F=E5=85=B3=E8=81=94?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fill/service/impl/GenerateServiceImpl.java | 24 +++++++++------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java index 3463168..f83a10c 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/fill/service/impl/GenerateServiceImpl.java @@ -284,20 +284,16 @@ public class GenerateServiceImpl extends BaseServiceImpl days(Date date) { List list = new ArrayList<>(); - // 结束日期 - Calendar endCal = Calendar.getInstance(); - endCal.setTime(new Date()); - endCal.add(Calendar.MONTH, -endCal.get(Calendar.MONTH) + 1); - endCal.add(Calendar.DATE, -endCal.get(Calendar.DATE) + 1); - - // 开始日期 - Calendar startCal = Calendar.getInstance(); - startCal.setTime(new Date()); - startCal.add(Calendar.DATE, -startCal.get(Calendar.DATE) + 1); - // 获取日期之间的月份 - while (endCal.after(startCal)) { - list.add(DateUtil.format(startCal.getTime(),DateUtil.PATTERN_DATE)); - startCal.add(Calendar.DAY_OF_MONTH, 1); + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.MONTH, 1); + calendar.add(Calendar.DAY_OF_MONTH, -calendar.get(Calendar.DAY_OF_MONTH) + 1); + Date end = calendar.getTime(); + calendar.add(Calendar.MONTH, -1); + Date start = calendar.getTime(); + while (start.compareTo(end) < 0){ + list.add(DateUtil.format(start,DateUtil.PATTERN_DATE)); + calendar.add(Calendar.DAY_OF_MONTH, 1); + start = calendar.getTime(); } return list; }