当java日期对象等于时,它不会返回任何结果,大于和小于工作正常但不相等,我需要做出哪些更改?
数据库中的数据类型为日期,值为" 13-JAN-14 05:00:00"和java模型对象数据类型是java.util.Date,日期值输出" Mon Jan 13 05:00:00 PST 2014"。我不知道为什么它的工作是平等的?
Constraint startDateConstraint = filter.getConstraint(MarketingOfferSearchFilter.Field.READY_DATE);
if (startDateConstraint != null) {
Expression<Date> startDate = marketingOffer.get(Offer_.startDate);
Date stDate = DateUtil.convertDifferentDateStringToUTCDate((String) startDateConstraint.getValue());
if (startDateConstraint.getCompareMode().equals(CompareMode.DATE_BEFORE)) {
predicates.add(builder.lessThan(startDate, stDate));
} else if (startDateConstraint.getCompareMode().equals(CompareMode.DATE_AFTER)) {
predicates.add(builder.greaterThan(startDate, stDate));
} else {
predicates.add(builder.equal(startDate, stDate));
}
}