I searched this issue but found only changing from String to Date and then displaying Date to String. I have a requirement, where I receive Date in String format and then I have to parse that in Date object and enter in Database.But whenever I convert String to Date it gives me wrong output. Please suggest. thanks in advance.
String subscribedDate="2012-09-28 11:00:00";
String oldFormat = "yyyy-mm-dd hh:mm:ss";
SimpleDateFormat sdf1 = new SimpleDateFormat(oldFormat);
Date dates=sdf1.parse(subscribedDate);
System.out.println(dates);
//code for entering dates in database.
Output: Sat Jan 28 00:09:00 GMT 2012 (Which is incorrect!!). I want as 2012-09-28 11:00:00