title: converting string date to sql Date format in java
body: <p>I would like to achieve below:</p>
  
  <p>I have date in string format as e.g. "2015-05-12 15:15:24", 
  I would like to convert it to sql date in the format "dd-MMM-yy". 
  However, this is not working. below is the code snippet:</p>
  
  <pre><code>    String rawDate="2015-05-12 15:15:24";
  
      SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      Date date =format.parse(rawDate);
      Date sqlDate = new java.sql.Date(date.getTime());
  
      SimpleDateFormat changedFormat = new SimpleDateFormat("dd-MMM-yy");
      Date date2=changedFormat.parse(changedFormat.format(sqlDate));
      Date sqlDate2 = new java.sql.Date(date2.getTime());
  
      System.out.println("sqlDate : "+sqlDate +"  ::::::   Date2 : "+date2+"  :::: sqlDate2  "+sqlDate2);ow here is the Test : "+sqlDate2);
  </code></pre>
  
  <p>The output of the program is :</p>
  
  <p>sqlDate : 2015-05-12  ::::::   Date2 : Tue May 12 00:00:00 BST 2015  :::: sqlDate2  2015-05-12</p>
  
  <p>The aim was to get date in the format of 12-May-15 java.sql format, but May is not being translated into alphabet month rather its printed as number.</p>
  
  <p>am I missing anything. any help would be appreciated.</p>