|
@@ -1,11 +1,5 @@
|
|
|
package org.jeecg.modules.adweb.common.util;
|
|
|
|
|
|
-import org.slf4j.Logger;
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
-import org.springframework.util.StringUtils;
|
|
|
-
|
|
|
-import java.text.ParseException;
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
import java.time.ZoneId;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -20,14 +14,6 @@ public class DateUtil {
|
|
|
|
|
|
public static final ZoneId DEFAULT_ZONE_ID = ZoneId.of("Asia/Shanghai");
|
|
|
|
|
|
- public static Date plusDays(Date date, int daysToAdd) {
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(date);
|
|
|
-
|
|
|
- calendar.add(Calendar.DAY_OF_MONTH, daysToAdd);
|
|
|
- return calendar.getTime();
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 特殊时间数据处理
|
|
|
*
|
|
@@ -38,20 +24,20 @@ public class DateUtil {
|
|
|
Date start = null;
|
|
|
Date end = null;
|
|
|
if ("yesterday".equals(dateType)) {
|
|
|
- start = getTodayZeroTime(DateUtil.addDay2(now, -1));
|
|
|
+ start = getTodayZeroTime(DateUtil.addDays(now, -1));
|
|
|
end = getTodayZeroTime(now);
|
|
|
}
|
|
|
if ("today".equals(dateType)) {
|
|
|
start = getTodayZeroTime(now);
|
|
|
- end = getTomZeroTime(now);
|
|
|
+ end = getTmrZeroTime(now);
|
|
|
}
|
|
|
if ("sevenDay".equals(dateType)) {
|
|
|
- end = getTomZeroTime(now);
|
|
|
- start = addDay2(end, -7);
|
|
|
+ end = getTmrZeroTime(now);
|
|
|
+ start = addDays(end, -7);
|
|
|
}
|
|
|
if ("thirtyDay".equals(dateType)) {
|
|
|
- end = getTomZeroTime(now);
|
|
|
- start = addDay2(end, -30);
|
|
|
+ end = getTmrZeroTime(now);
|
|
|
+ start = addDays(end, -30);
|
|
|
}
|
|
|
Map<String, Date> map = new HashMap<>();
|
|
|
map.put("start", start);
|
|
@@ -61,6 +47,7 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 获取当日零点
|
|
|
+ *
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
@@ -76,10 +63,11 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 获取明日零点
|
|
|
+ *
|
|
|
* @param date
|
|
|
* @return
|
|
|
*/
|
|
|
- public static Date getTomZeroTime(Date date) {
|
|
|
+ public static Date getTmrZeroTime(Date date) {
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(date);
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
@@ -92,15 +80,15 @@ public class DateUtil {
|
|
|
|
|
|
/**
|
|
|
* 在当前日期上追加N天
|
|
|
+ *
|
|
|
* @param date 当前日期
|
|
|
* @param num 添加天数
|
|
|
* @return 日期字符串形式
|
|
|
*/
|
|
|
- public static Date addDay2(Date date, int num) {
|
|
|
+ public static Date addDays(Date date, int num) {
|
|
|
Calendar c = Calendar.getInstance();
|
|
|
c.setTime(date);
|
|
|
c.add(Calendar.DAY_OF_MONTH, num);
|
|
|
return c.getTime();
|
|
|
}
|
|
|
}
|
|
|
-
|