1

In my app i need to search an order by his creation_date. In my entity, the type of the creationDate field is java.time.Instant.

In my class ManualOrderSpecification i need to check the creation_date.

I would like to compare the date of creation without the hours or with the same hour (0 hour for example).

My code :

 if (searchBean.getCreatedDate() != null) {
                    Instant createdInstantFromForm = ZonedDateTime.of(searchBean.getCreatedDate(), LocalTime.of(0, 0, 0, 0), ZoneId.systemDefault()).toInstant();                                  
                                         p.getExpressions().add(criteriaBuilder.equal(root.get(ManualOrder_.createdDate), createdInstantFromForm ));
                } 

Of course it doesn't work because i compare the same date but with different hours, 0 hour to another hours. How can i force to compare to a localdate or can i force to 0 hours the root.get(ManualOrder_.createdDate) attribute ?

Many thanks

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
loic
  • 511
  • 1
  • 4
  • 5

0 Answers0