spring-mongodb 时间区间查询

Query query = new Query();


SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");//时间格式要与mongodb对应

startDate = format.parse(filter.getValue().toString().replaceAll("-", "/"));


SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
endDate = format.parse(filter.getValue().toString().replaceAll("-", "/"));


query.addCriteria(Criteria.where("createtime").gte(startDate).lte(endDate));

你可能感兴趣的:(spring-mongodb)