From 72e5ccac8a6f3bb06e07c327663a956b6d2fc001 Mon Sep 17 00:00:00 2001 From: xhxu Date: Sun, 22 Aug 2021 21:09:21 +0800 Subject: [PATCH] rent --- .../java/com/iformall/utils/DateUtils.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java index d6ad97f55..5736554e7 100755 --- a/mallinkService/src/main/java/com/iformall/utils/DateUtils.java +++ b/mallinkService/src/main/java/com/iformall/utils/DateUtils.java @@ -349,11 +349,10 @@ public class DateUtils { * @return */ public static String getTimeBefore(int days, Date myDate) { - Date testDate = myDate; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); - long myTime = (testDate.getTime() / 1000) - 60 * 60 * 24 * days; - testDate.setTime(myTime * 1000); - return formatter.format(testDate); + long myTime = (myDate.getTime() / 1000) - 60 * 60 * 24 * days; + Date date = new Date(myTime * 1000); + return formatter.format(date); } /** @@ -364,12 +363,10 @@ public class DateUtils { * @return */ public static String getTimeBefore(int days, Date myDate,String format) { - Date testDate = myDate; SimpleDateFormat formatter = new SimpleDateFormat(format); - long myTime = (testDate.getTime() / 1000) - 60 * 60 * 24 * days; - testDate.setTime(myTime * 1000); - String mDate = formatter.format(testDate); - return mDate; + long myTime = (myDate.getTime() / 1000) - 60 * 60 * 24 * days; + Date date = new Date(myTime * 1000); + return formatter.format(date); } /** @@ -380,12 +377,10 @@ public class DateUtils { * @return */ public static String getHourTimeBefore(int hour, Date myDate) { - Date testDate = myDate; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - long myTime = (testDate.getTime() / 1000) - 60 * 60 * hour; - testDate.setTime(myTime * 1000); - String mDate = formatter.format(testDate); - return mDate; + long myTime = (myDate.getTime() / 1000) - 60 * 60 * hour; + Date date = new Date(myTime * 1000); + return formatter.format(date); } /**