title: JPA2 Criteria and Java 8 Date&Time API
body: <p>I try to port a Java web application to the new Java 8 Date&amp;Time API (using 'LocalDate' and 'LocalDateTime' types among others)</p>
  
  <p>In Java 7, java.util.Date could be used in JPA2 criteria API to filter result sets on dates. Typically one would do this by adding a predicate e.g.</p>
  
  <pre><code>..
  predicatesList.add(builder.between(from.get(AccountLog_.valueDate), fromDate, toDate));
  ..
  </code></pre>
  
  <p>Now JPA2 doesn't support the new Java 8 Date&amp;Time API (LocalDate and LocalDateTime) yet. With own "Attribute Converters", working with entities can already be achieved as described in the blog <a href="http://www.thoughts-on-java.org/persist-localdate-localdatetime-jpa/">http://www.thoughts-on-java.org/persist-localdate-localdatetime-jpa/</a></p>
  
  <p>Now to my question: how can I use LocalDate and LocalDateTime in JPA2 criteria API in order to filter the result sets on <strong>LocalDate</strong> instead of Date? 'between' as used previously doesn't work for LocalDate instances.</p>