修改es开始时间和截至时间报错问题
This commit is contained in:
@@ -718,11 +718,15 @@ public class ESJobSearchImpl implements IESJobSearchService
|
|||||||
wrapper.and(a->a.eq(ESJobDocument::getType,jobQuery.getType().trim()));
|
wrapper.and(a->a.eq(ESJobDocument::getType,jobQuery.getType().trim()));
|
||||||
}
|
}
|
||||||
//开始时间
|
//开始时间
|
||||||
if (Objects.nonNull(jobQuery.getStartDate())) {
|
Date startDate = jobQuery.getStartDate();
|
||||||
wrapper.ge(ESJobDocument::getPostingDate, jobQuery.getStartDate());
|
Date endDate = jobQuery.getEndDate();
|
||||||
|
if (Objects.nonNull(startDate)) {
|
||||||
|
String startStr = DateUtils.UTC_FORMATTER.format(startDate.toInstant());
|
||||||
|
wrapper.ge(ESJobDocument::getPostingDate, startStr);
|
||||||
}
|
}
|
||||||
if (Objects.nonNull(jobQuery.getEndDate())) {
|
if (Objects.nonNull(endDate)) {
|
||||||
wrapper.le(ESJobDocument::getPostingDate, jobQuery.getEndDate());
|
String endStr = DateUtils.UTC_FORMATTER.format(endDate.toInstant());
|
||||||
|
wrapper.le(ESJobDocument::getPostingDate, endStr);
|
||||||
}
|
}
|
||||||
// 先开启打分、优先按匹配分数排序(关键词前台命中越高越靠前)
|
// 先开启打分、优先按匹配分数排序(关键词前台命中越高越靠前)
|
||||||
wrapper.trackScores();
|
wrapper.trackScores();
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||||
|
|
||||||
@@ -36,6 +37,10 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||||
|
|
||||||
|
public static final DateTimeFormatter UTC_FORMATTER = DateTimeFormatter
|
||||||
|
.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||||
|
.withZone(ZoneId.of("UTC"));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前Date型日期
|
* 获取当前Date型日期
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user