title: SimpleDateFormat producing wrong date time when parsing "YYYY-MM-dd HH:mm"
body: <p>I am trying to parse a <code>String</code> (<code>YYYY-MM-dd HH:mm</code>) to <code>Date</code>, however getting wrong date than expected.</p>
  
  <p>CODE:</p>
  
  <pre><code>Date newDate = null;
  String dateTime = "2013-03-18 08:30";
  SimpleDateFormat df = new SimpleDateFormat("YYYY-MM-dd HH:mm", Locale.ENGLISH);
  df.setLenient(false);
  try {
      newDate = df.parse(dateTime);
  } catch (ParseException e) {
      throw new InvalidInputException("Invalid date input.");
  }
  </code></pre>
  
  <p>Produces:</p>
  
  <blockquote>
    <p>Sun Dec 30 08:30:00 EST 2012 (wrong)</p>
  </blockquote>
  
  <p>I tried setting Lenient off but no luck.</p>
  
  <p><strong>Update</strong></p>
  
  <p>Thanks Sudhanshu for the answer, it helped me to solve the Java conversion. When I enter the returned date from the above code into the database I am getting the date correctly but the time is always <code>00:00</code>.</p>
  
  <pre><code>ps.setDate(3, new java.sql.Date(app.getDate().getTime()));
  </code></pre>