From 8ae6926bd6a85ca6af96e580e7d618cb7d3fa059 Mon Sep 17 00:00:00 2001 From: jaysunxiao Date: Tue, 23 Nov 2021 12:56:31 +0800 Subject: [PATCH] =?UTF-8?q?fix[time]:=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E5=91=A8=E6=97=B6=E9=97=B4=E5=B8=B8=E9=87=8F=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/zfoo/scheduler/util/TimeUtils.java | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/scheduler/src/main/java/com/zfoo/scheduler/util/TimeUtils.java b/scheduler/src/main/java/com/zfoo/scheduler/util/TimeUtils.java index 4f1b4af4..03254f21 100644 --- a/scheduler/src/main/java/com/zfoo/scheduler/util/TimeUtils.java +++ b/scheduler/src/main/java/com/zfoo/scheduler/util/TimeUtils.java @@ -44,7 +44,7 @@ public abstract class TimeUtils { // 一天对应的毫秒数 public static final long MILLIS_PER_DAY = 1 * 24 * MILLIS_PER_HOUR; // 一周对应的毫秒数 - public static final long MILLIS_PER_WEEK = 1 * 7 * MILLIS_PER_HOUR; + public static final long MILLIS_PER_WEEK = 1 * 7 * MILLIS_PER_DAY; // 默认的时区 public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault(); // 默认的时区Id @@ -215,19 +215,13 @@ public abstract class TimeUtils { int yearDiff = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR); if (yearDiff == 0 && cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) { // yearDiff==0,说明是同一年 - if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) { - return true; - } + return cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR); } else if (yearDiff == 1 && cal2.get(Calendar.MONTH) == 11) { //yearDiff==1,说明cal比cal2大一年;java的一月用"0"标识,那么12月用"11" - if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) { - return true; - } + return cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR); } else if (yearDiff == -1 && cal1.get(Calendar.MONTH) == 11) { //yearDiff==-1,说明cal比cal2小一年 - if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) { - return true; - } + return cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR); } return false; }