Commit 540b8cfe authored by yanzg's avatar yanzg

Merge remote-tracking branch 'origin/ver1.1' into ver1.1

parents 41534ee4 50194853
...@@ -363,6 +363,46 @@ public class DateHelper { ...@@ -363,6 +363,46 @@ public class DateHelper {
return end.getTime(); return end.getTime();
} }
/**
* 获取本周开始日期
*
* @param date 某一天
* @return 返回的日期
*/
public static Date getWeekStart(Date date) {
Calendar cal = getDayCalendarBegin(date);
// 周日
int weekOfYear;
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
weekOfYear = cal.get(Calendar.WEEK_OF_YEAR) - 1;
} else {
weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
}
cal.setWeekDate(cal.getWeekYear(), weekOfYear, 2);
setDayStart(cal);
return cal.getTime();
}
/**
* 获取本周结束日期
*
* @param date 某一天
* @return 返回的值
*/
public static Date getWeekEnd(Date date) {
Calendar cal = getDayCalendarBegin(date);
// 周日
int weekOfYear;
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);
} else {
weekOfYear = cal.get(Calendar.WEEK_OF_YEAR) + 1;
}
cal.setWeekDate(cal.getWeekYear(), weekOfYear, 1);
setDayEnd(cal);
return cal.getTime();
}
/** /**
* 获取本月开始时间 * 获取本月开始时间
......
...@@ -1278,6 +1278,9 @@ public class StringHelper { ...@@ -1278,6 +1278,9 @@ public class StringHelper {
while (handle) { while (handle) {
handle = false; handle = false;
for (String prefix : suffix) { for (String prefix : suffix) {
if (StringHelper.isEmpty(prefix)) {
continue;
}
if (from.startsWith(prefix)) { if (from.startsWith(prefix)) {
from = from.substring(prefix.length()); from = from.substring(prefix.length());
handle = true; handle = true;
...@@ -1302,6 +1305,9 @@ public class StringHelper { ...@@ -1302,6 +1305,9 @@ public class StringHelper {
while (handle) { while (handle) {
handle = false; handle = false;
for (String prefix : suffix) { for (String prefix : suffix) {
if (StringHelper.isEmpty(prefix)) {
continue;
}
if (from.endsWith(prefix)) { if (from.endsWith(prefix)) {
from = from.substring(0, from.length() - prefix.length()); from = from.substring(0, from.length() - prefix.length());
handle = true; handle = true;
......
...@@ -14,10 +14,19 @@ public class TestDateHelper { ...@@ -14,10 +14,19 @@ public class TestDateHelper {
Date date = new Date(); Date date = new Date();
System.out.println("本日:" + DateHelper.getDateTimeString(DateHelper.getDayStart(date))); System.out.println("本日:" + DateHelper.getDateTimeString(DateHelper.getDayStart(date)));
System.out.println("本日:" + DateHelper.getDateTimeString(DateHelper.getDayEnd(date))); System.out.println("本日:" + DateHelper.getDateTimeString(DateHelper.getDayEnd(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearStart(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearEnd(date)));
System.out.println("本月:" + DateHelper.getDateTimeString(DateHelper.getMonthStart(date))); System.out.println("本月:" + DateHelper.getDateTimeString(DateHelper.getMonthStart(date)));
System.out.println("本月:" + DateHelper.getDateTimeString(DateHelper.getMonthEnd(date))); System.out.println("本月:" + DateHelper.getDateTimeString(DateHelper.getMonthEnd(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearStart(date)));
System.out.println("本年:" + DateHelper.getDateTimeString(DateHelper.getYearEnd(date)));
System.out.println("本周:" + DateHelper.getDateTimeString(DateHelper.getWeekStart(date)));
System.out.println("本周:" + DateHelper.getDateTimeString(DateHelper.getWeekEnd(date)));
System.out.println("2022-11-27 周:" + DateHelper.getDateTimeString(DateHelper.getWeekStart(DateHelper.getDateTime("2022-11-27"))));
System.out.println("2022-11-27 周:" + DateHelper.getDateTimeString(DateHelper.getWeekEnd(DateHelper.getDateTime("2022-11-27"))));
System.out.println("2022-11-26 周:" + DateHelper.getDateTimeString(DateHelper.getWeekStart(DateHelper.getDateTime("2022-11-26"))));
System.out.println("2022-11-26 周:" + DateHelper.getDateTimeString(DateHelper.getWeekEnd(DateHelper.getDateTime("2022-11-26"))));
System.out.println("本季度:" + DateHelper.getDateTimeString(DateHelper.getMonth3Start(date))); System.out.println("本季度:" + DateHelper.getDateTimeString(DateHelper.getMonth3Start(date)));
System.out.println("本季度:" + DateHelper.getDateTimeString(DateHelper.getMonth3End(date))); System.out.println("本季度:" + DateHelper.getDateTimeString(DateHelper.getMonth3End(date)));
......
...@@ -62,7 +62,8 @@ public class AspectMq { ...@@ -62,7 +62,8 @@ public class AspectMq {
String requestBody = aspectLogBody.getRequestBody(message); String requestBody = aspectLogBody.getRequestBody(message);
LogVo log = new LogVo(); LogVo log = new LogVo();
boolean clear = aspectLogStart.requestLogInit(); boolean clear = true;
aspectLogStart.requestLogInit();
aspectLogStart.requestLog(declaringType, TAG, url, requestBody, log, clear); aspectLogStart.requestLog(declaringType, TAG, url, requestBody, log, clear);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Object result = null; Object result = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment