title: How to best compare if the time part of a Date is between two LocalTime values with querydsl?
body: <p>QueryDSL Version 4.1.4 - upgrade not possible at the moment</p>
  
  <p>How to best compare if the time part of a Date is between two LocalTime values with QueryDSL?</p>
  
  <p>Declaration:</p>
  
  <pre class="lang-java prettyprint-override"><code>private java.time.LocalTime.LocalTime beginTime; -&gt; TIME in postgresql
  private java.time.LocalTime.LocalTime endTime;  -&gt; TIME in postgresql
  private java.util.Date calltime; -&gt; TIMESTAMP in postgresql
  </code></pre>
  
  <hr>
  
  <p>Expressions:</p>
  
  <pre class="lang-java prettyprint-override"><code>TimeExpression&lt;Date&gt; calltimeTimePath = Expressions.asTime(qTicket.calltime);
  TimePath&lt;LocalTime&gt; beginTimePath = qCallCenterTimeslot.beginTime;
  TimePath&lt;LocalTime&gt; endTimePath = qCallCenterTimeslot.endTime;
  </code></pre>
  
  <hr>
  
  <p>Predicate:</p>
  
  <pre class="lang-java prettyprint-override"><code>.where(calltimeTimePath.between(beginTimePath, endTimePath));
  </code></pre>
  
  <blockquote>
    <p>Exception: Cannot resolve method 'between(com.querydsl.core.type.dsl.TimePath, com.querydsl.core.type.dsl.TimePath)'</p>
  </blockquote>
  
  <p>Working example:</p>
  
  <pre><code>TimeExpression&lt;LocalTime&gt; testTimeExpression = Expressions.asTime(test);
  
  .where(testTimeExpression.between(beginTimeExpression, endTimeExpression))
  </code></pre>
  
  <p>So maybe the best way would be to convert TimeExpression from Date to TimeExpression from LocalTime. But I've no clue how to achieve this?</p>
  
  <hr>
  
  <p>In postgresql I can simply do:</p>
  
  <pre class="lang-sql prettyprint-override"><code>SELECT t.calltime::TIME, *
  FROM ticket t
       INNER JOIN call_center_timeslot c
               ON c.id=218
              AND t.calltime::TIME BETWEEN c.begin_time AND c.end_time;
  </code></pre>
  
  <p>Any thoughts how to best solve it?</p>