title: Get the current date in java.sql.Date format
body: <p>I need to add the current date into a prepared statement of a JDBC call. I need to add the date in a format like <code>yyyy/MM/dd</code>.</p>
  
  <p>I've try with</p>
  
  <pre><code>DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
  Date date = new Date();
  pstm.setDate(6, (java.sql.Date) date);
  </code></pre>
  
  <p>but I have this error:</p>
  
  <pre><code>threw exception
  java.lang.ClassCastException: java.util.Date cannot be cast to java.sql.Date
  </code></pre>
  
  <p>Is there a way to obtain a <code>java.sql.Date</code> object with the same format?</p>