@Test public void testResetTimeToMidnight() throws DatatypeConfigurationException { XMLGregorianCalendar gregorianCalendar = DatatypeFactory.newInstance().newXMLGregorianCalendar("2015-12-21T21:32:52"); Timestamp result = HerdDateUtils.resetTimeToMidnight(gregorianCalendar); assertEquals(Timestamp.valueOf("2015-12-21 00:00:00.0"), result); } }
/** * Apply a predicate for registration date range filter. * * @param registrationDateRangeFilter the registration date range filter, not null * @param businessObjectDataEntity the business object data entity * @param builder the query builder * @param predicate the predicate to be updated * * @return the predicate with added registration date range filter */ private Predicate applyRegistrationDateRangeFilter(RegistrationDateRangeFilter registrationDateRangeFilter, Root<BusinessObjectDataEntity> businessObjectDataEntity, CriteriaBuilder builder, Predicate predicate) { // Apply predicate for registration start date and removed the time portion of the date. if (registrationDateRangeFilter.getStartRegistrationDate() != null) { predicate = builder.and(predicate, builder.greaterThanOrEqualTo(businessObjectDataEntity.get(BusinessObjectDataEntity_.createdOn), HerdDateUtils.resetTimeToMidnight(registrationDateRangeFilter.getStartRegistrationDate()))); } // Apply predicate for registration end date. Removed time portion of the date and added one day to get the result till the end of the day if (registrationDateRangeFilter.getEndRegistrationDate() != null) { predicate = builder.and(predicate, builder.lessThan(businessObjectDataEntity.get(BusinessObjectDataEntity_.createdOn), HerdDateUtils.addDays(HerdDateUtils.resetTimeToMidnight(registrationDateRangeFilter.getEndRegistrationDate()), 1))); } return predicate; }
/** * Apply a predicate for registration date range filter. * * @param registrationDateRangeFilter the registration date range filter, not null * @param businessObjectDataEntity the business object data entity * @param builder the query builder * @param predicate the predicate to be updated * * @return the predicate with added registration date range filter */ private Predicate applyRegistrationDateRangeFilter(RegistrationDateRangeFilter registrationDateRangeFilter, Root<BusinessObjectDataEntity> businessObjectDataEntity, CriteriaBuilder builder, Predicate predicate) { // Apply predicate for registration start date and removed the time portion of the date. if (registrationDateRangeFilter.getStartRegistrationDate() != null) { predicate = builder.and(predicate, builder.greaterThanOrEqualTo(businessObjectDataEntity.get(BusinessObjectDataEntity_.createdOn), HerdDateUtils.resetTimeToMidnight(registrationDateRangeFilter.getStartRegistrationDate()))); } // Apply predicate for registration end date. Removed time portion of the date and added one day to get the result till the end of the day if (registrationDateRangeFilter.getEndRegistrationDate() != null) { predicate = builder.and(predicate, builder.lessThan(businessObjectDataEntity.get(BusinessObjectDataEntity_.createdOn), HerdDateUtils.addDays(HerdDateUtils.resetTimeToMidnight(registrationDateRangeFilter.getEndRegistrationDate()), 1))); } return predicate; }