在es中有的时候会查询某个时间段的会返回+1天日期的数据
1995-10-01T00:00:00+08:00
beginTime = TimeUtil.timeAddDays(TimeUtil.strToDate(beginTime), -1);
boolQueryBuilder.must(QueryBuilders.rangeQuery("time").gte(beginTime));
endTime = TimeUtil.timeAddDays(TimeUtil.strToDate(endTime), -1);
boolQueryBuilder.must(QueryBuilders.rangeQuery("time").lte(endTime));
public static String timeAddDays(Date date, int days) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.DATE, days);
Date date2 = calendar.getTime();
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
return df.format(date2);
}