fix(接口测试): 七天时间范围的判定从周日到周六改为从周一到周日
--bug=1017103 --user=宋天阳 【接口测试】接口测试首页场景用例数量统计本周执行次数不正确 {#_orginal_url#}
This commit is contained in:
parent
63fec14298
commit
8cc8729699
|
@ -77,25 +77,18 @@ public class DateUtils {
|
||||||
public static Map<String, Date> getWeedFirstTimeAndLastTime(Date date) {
|
public static Map<String, Date> getWeedFirstTimeAndLastTime(Date date) {
|
||||||
Map<String, Date> returnMap = new HashMap<>();
|
Map<String, Date> returnMap = new HashMap<>();
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setFirstDayOfWeek(Calendar.MONDAY);
|
||||||
//Calendar默认一周的开始是周日。业务需求从周一开始算,所以要"+1"
|
|
||||||
int weekDayAdd = 1;
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
calendar.setTime(date);
|
int dayWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
||||||
calendar.set(Calendar.DAY_OF_WEEK, calendar.getActualMinimum(Calendar.DAY_OF_WEEK));
|
if (dayWeek == 1) {
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, weekDayAdd);
|
dayWeek = 8;
|
||||||
|
}
|
||||||
|
calendar.add(Calendar.DATE, calendar.getFirstDayOfWeek() - dayWeek);
|
||||||
//第一天的时分秒是 00:00:00 这里直接取日期,默认就是零点零分
|
//第一天的时分秒是 00:00:00 这里直接取日期,默认就是零点零分
|
||||||
Date thisWeekFirstTime = getDate(getDateString(calendar.getTime()));
|
Date thisWeekFirstTime = getDate(getDateString(calendar.getTime()));
|
||||||
|
|
||||||
calendar.clear();
|
//计算七天过后的日期
|
||||||
calendar.setTime(date);
|
calendar.add(Calendar.DATE, 7);
|
||||||
calendar.set(Calendar.DAY_OF_WEEK, calendar.getActualMaximum(Calendar.DAY_OF_WEEK));
|
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, weekDayAdd);
|
|
||||||
|
|
||||||
//最后一天的时分秒应当是23:59:59。 处理方式是增加一天计算日期再-1
|
|
||||||
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
|
||||||
Date nextWeekFirstDay = getDate(getDateString(calendar.getTime()));
|
Date nextWeekFirstDay = getDate(getDateString(calendar.getTime()));
|
||||||
Date thisWeekLastTime = getTime(getTimeString(nextWeekFirstDay.getTime() - 1));
|
Date thisWeekLastTime = getTime(getTimeString(nextWeekFirstDay.getTime() - 1));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue