title: change date format to query database
body: <p>how do I change date format of the following date</p>
  
  <pre><code>Thu May 17 00:00:00 GMT+05:30 2012
  </code></pre>
  
  <p>to</p>
  
  <pre><code>2012-05-17 00:00:00
  </code></pre>
  
  <p>I need it as date and not as string. I am using </p>
  
  <pre><code>new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse("")
  </code></pre>
  
  <p>But its not giving the result. 
  Actually I am storing the values date wise. So when someone enters the data for the same date again it should overwrite.
  If I pass it as date object into the hibernate query it gives the result. But not always. ON few occasions it inserts again that is it inserts duplicate data for the same date. Befroe entering I am adding a method to check if data exists for that date. <code>criteria.add(Restrictions.eq("date", date));</code></p>