title: Get Date object from String in form 2012-07-26 23:59:59
body: <p>I have the input string as <code>2012-07-27</code> and I want the output as <strong><code>Date</code></strong> but with the same format like <code>2012-07-27</code></p>
  
  <h3>Code</h3>
  
  <pre><code> DateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  
          try {
              Date today = df.parse("20-12-2005 23:59:59");
              System.out.println("Today = " + df.format(today));
  
                       } catch (ParseException e) {
              e.printStackTrace();
          }
  </code></pre>
  
  <h3>Output</h3>
  
  <pre><code>20-12-2005 23:59:59
  </code></pre>
  
  <p>But it's string object I want the same output (<code>20-12-2005 23:59:59</code>) as date object not as string object.</p>
  
  <p>How can I get the <strong><code>Date</code></strong> in the form <code>DD-MM-YYYY HH:MM:SS</code>?</p>