title: Convert String to date in to yyyy-MM-dd for jUnit test
body: <p>I am doing junit test for a method in the dao layer which requires to pass date value in the format to use in the SQL query. I have the date string <code>"2006-08-14"</code> and tried to convert into date using the following code.</p>
  
  <pre><code>SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  Date date2 = sdf.parse("2006-08-14");
  ...
  projectSchedule.setDate(date2);
  </code></pre>
  
  <p>The above code sets the value as</p>
  
  <pre><code> Mon Aug 14 00:00:00 GST 2006
  </code></pre>
  
  <p>This fails in the DAO layer because the query expects the date in the format yyyy-MM-dd</p>
  
  <pre><code>select * from projects_bidders pb, projects_bidders_type pbt  where   cde_project = :projectId and cde_phase = :phaseId and  phase_start_date =  :phaseDate and foreign_id is not null and id_bidder = cde_bidder
  </code></pre>
  
  <p><code>query.setParameter("phaseDate", projectSchedule.getDate());</code></p>
  
  <p>I referred many questions in in SO and didn't find any thing suitable.</p>
  
  <p>I don't have control on DAO layer.</p>