mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-10-18 14:14:26 +00:00
fix[time]: 修复一周时间常量错误
This commit is contained in:
1 parent
d7e6f7ba7b
commit
8ae6926bd6
1 file changed
+4
-10
@@ -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_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();
|
public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
|
||||||
// 默认的时区Id
|
// 默认的时区Id
|
||||||
@@ -215,19 +215,13 @@ public abstract class TimeUtils {
|
|||||||
int yearDiff = cal1.get(Calendar.YEAR) - cal2.get(Calendar.YEAR);
|
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)) {
|
if (yearDiff == 0 && cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) {
|
||||||
// yearDiff==0,说明是同一年
|
// yearDiff==0,说明是同一年
|
||||||
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) {
|
return cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (yearDiff == 1 && cal2.get(Calendar.MONTH) == 11) {
|
} else if (yearDiff == 1 && cal2.get(Calendar.MONTH) == 11) {
|
||||||
//yearDiff==1,说明cal比cal2大一年;java的一月用"0"标识,那么12月用"11"
|
//yearDiff==1,说明cal比cal2大一年;java的一月用"0"标识,那么12月用"11"
|
||||||
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) {
|
return cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else if (yearDiff == -1 && cal1.get(Calendar.MONTH) == 11) {
|
} else if (yearDiff == -1 && cal1.get(Calendar.MONTH) == 11) {
|
||||||
//yearDiff==-1,说明cal比cal2小一年
|
//yearDiff==-1,说明cal比cal2小一年
|
||||||
if (cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR)) {
|
return cal1.get(Calendar.WEEK_OF_YEAR) == cal2.get(Calendar.WEEK_OF_YEAR);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user