title: Converting string to date format (yyyy/MM/dd) in JAVA
body: <p>I am facing an issue when I convert my string to date format.</p>
  
  <p>This is what I have tried -</p>
  
  <p>First try:</p>
  
  <pre><code>        String completionDate1 = request.getParameter("completion_date");
          System.out.println(completionDate1); // O/P --&gt; 21/10/2016 (Correct)
          DateFormat df = new SimpleDateFormat("yyyy/MM/dd");
          Date date = new Date();
          date = df.parse(completionDate1);
          System.out.println(date); // O/P --&gt; Tue Apr 08 00:00:00 IST 27 (Inorrect)
  </code></pre>
  
  <p>Second try:</p>
  
  <pre><code>        String completionDate1 = request.getParameter("completion_date");
          System.out.println(completionDate1); // O/P --&gt; 21/10/2016 (Correct)
          Date completionDate = new SimpleDateFormat("yyyy/MM/dd").parse(completionDate1);
          System.out.println(completionDate); // O/P --&gt; Tue Apr 08 00:00:00 IST 27 (Inorrect)
  </code></pre>
  
  <p>The output I'm expecting is that, the <code>completionDate</code> should be <code>Date</code> format not <code>String</code>. I'm just printing the completionDate just to make sure the date format is getting getting converted. </p>
  
  <p>The main intention of getting it in date format is I need this for an Update query so it has to be Date and not String.</p>
  
  <p>Kindly let me know where I'm going wrong. I need this date format as I need to store this date in a database.</p>
  
  <p>Thanks</p>