title: Converting Joda LocalTime to java.sql.Date
body: <p>To make a JDBC query I need to pass date to it. The date is kept in <a href="http://www.postgresql.org/docs/9.1/static/datatype-datetime.html" rel="noreferrer"><code>Date</code> field</a> type of PostgreSql database, which represents specific day without any time.</p>
  
  <p>As I need only date, I decided to use specific object which represent only date without time, which is <a href="http://joda-time.sourceforge.net/apidocs/org/joda/time/LocalDate.html" rel="noreferrer"><code>LocalDate</code> from Joda-Time package</a>. I thought it is important because if I used DateTime object, it would carry redundant time data as well as it might lead to bugs at end of daylight saving time when the clock are put backward one hour (though the situation is unprecedentedly rare, it's not impossible).</p>
  
  <p>But when I started trying to square <code>LocalDate</code> object with accepted arguments of <code>preparedStatement.setDate</code> method, I didn't find a proper way to do it.</p>
  
  <p><code>setDate</code> accepts <code>java.sql.Date</code> as parameter. And the only option to construct <code>java.sql.Date</code> object is to pass it time in milliseconds.</p>
  
  <p>But this defeats all the purpose of using <code>LocalDate</code> from Joda-Time package, as on this conversion we get back to milliseconds and, while these conversions happen, clock may be put back one hour and change the date to the previous date.</p>
  
  <p>So, now I have this line in my code:</p>
  
  <pre><code>preparedStatement.setDate(1, new java.sql.Date(localDate.toDate().getTime()));
  </code></pre>
  
  <p>But is this the best way to convert <code>LocalDate</code> to accepted by <code>setDate</code> format?</p>
  
  <p>Are my concerns related to daylight saving time and corresponding clock-shifts justified?</p>
  
  <p>Is there a better way to pass date (and only date without time) to JDBC preparedStatement?</p>