From 52f34e797142b8994b963541ca55f374b36d9aa6 Mon Sep 17 00:00:00 2001 From: luozukai Date: Wed, 29 May 2019 15:53:58 +0800 Subject: [PATCH] =?UTF-8?q?[bug][=E4=BF=AE=E6=94=B9][1001665]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iformall/service/impl/WxRentContractServiceImpl.java | 4 ++-- .../src/main/java/com/iformall/utils/DateUtils.java | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java index 5c54eb4bc..6cb84e595 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxRentContractServiceImpl.java @@ -1747,7 +1747,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { public static double getNeedPay(long monthPrice,long dayPrice,Date start,Date end){ SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdM = new SimpleDateFormat("MM"); - Double total = new Double(0); + Double total; int[] diff; int dayCount = DateUtils.getMonthDayCount(start); @@ -1763,7 +1763,7 @@ public class WxRentContractServiceImpl implements WxRentContractService { System.out.println(sd.format(start)); System.out.println(sd.format(currEnd)); - if(sdM.format(start).equals(sdM.format(end))){ + if(sd.format(start).equals(sd.format(end))){ total = 1 * price; //算1天 return total; }else{ diff --git a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java index 6e9230453..b6b3a221c 100755 --- a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java +++ b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java @@ -1092,8 +1092,12 @@ public class DateUtils { * @return */ public static int[] getDiff(Date startDate,Date endDate) { - ZoneId zone = ZoneId.systemDefault(); + SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd"); + if(sd.format(startDate).equals(sd.format(endDate))){ + return new int[] {0, 1}; + } + ZoneId zone = ZoneId.systemDefault(); LocalDateTime localDateTime = LocalDateTime.ofInstant(startDate.toInstant(), zone); LocalDate start = localDateTime.toLocalDate();