String (dd-MM-yyyy HH:mm) to Date (yyyy-MM-dd HH:mm) | Java
- by Panther24
I have a string in "dd-MM-yyyy HH:mm" and need to convert it to a date object in the format
"yyyy-MM-dd HH:mm".
Below is the code I'm using to convert
oldScheduledDate = "16-05-2011 02:00:00";
DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date oldDate = (Date)formatter.parse(oldScheduledDate);
Now when I print oldDate, i get
Sat Nov 01 02:00:00 GMT 21, which is completely wrong, what am I doing wrong here?