SimpleDateFormat producing wrong date time when parsing "YYYY-MM-dd HH:mm"

YYYY should be yyyy-

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.ENGLISH);

Please check the documentation for SimpleDateFormat here
Java 6 : http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html
Java 7 : http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html


Use small case Y, not caps. ie yyyy not YYYY

Check the comments here: Java Simple Date Format and other answers referenced there.


There are two problem.

  1. Format string should be "yyyy-MM-dd HH:mm".
  2. Datatype to store the time is TimeStamp and not Date in database.

Correct both the things and you will be able to store and retrieve Date with time.