I have date string of the format 8/1/2011 04:06 am. I want it to convert it in to the date string of the format 2011-08-1T16:06:00-04:00 using DateFormat. I am using the code
private String formatDate(String date) {
SimpleDateFormat curFormater = new SimpleDateFormat("dd/MM/yyyy hh:mm a");
Date dateObj = null;
try {
dateObj = curFormater.parse(date);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String format = "yyyy-MM-dd'T'HH:mmZ";
String date = (String) DateFormat.format(format, dateObj);
return date;
}
But it returns the String 2011-01-08THH:37Z.
Can any one please help me with this?