title: JPA specification for Joda-Time comparison
body: <p>I am trying to get orders specific to a range using JPA specifications.</p>
  
  <p>Please find below code and my domain class. Date types are from Joda-Time, but unable to match with that date though.</p>
  
  <pre><code>public static Specification&lt;BnvOrder&gt; byStatusChangedDateRange(String statusName, String fromDate, String toDate) {
          DateTimeFormatter format = DateTimeFormat.forPattern("YYYY-MM-dd");
          LocalDateTime fromDateTime = format.parseLocalDateTime(fromDate);
  //      LocalDateTime toDateTime = format.parseLocalDateTime(toDate+" 00:00:00");
          return new Specification&lt;BnvOrder&gt;() {
              @Override
              public Predicate toPredicate(Root&lt;BnvOrder&gt; root, CriteriaQuery&lt;?&gt; query, CriteriaBuilder cb) {
  
  //              return cb.and(cb.lessThanOrEqualTo(root.&lt;LocalDateTime&gt;get(statusName), fromDateTime),
  //                      cb.greaterThanOrEqualTo(root.&lt;LocalDateTime&gt;get(statusName), toDateTime));
  //              cb.greaterThanOrEqualTo("DATE("+root.get("deliveryEndDate")+")", fromDateTime);
                  return cb.between(root.get("deliveryEndDate"),fromDateTime,fromDateTime);
              }
          };
      }
  </code></pre>