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; }