INPUT:
SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
SimpleDateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
String unformattedDate = "2013-11-16T08:46:00.000-06:00";
String formattedDate = outFormat.format(inFormat.parse(unformattedDate ));
ABOVE OUTPUT:
formattedDate = "2013-11-16T20:16:00.000Z"
DESIRED OUTPUT:
formattedDate = "2013-11-16T08:46:00.000Z"
Can anyone through a light on why is this difference after conversion and how to get the desired output?
I assume that my inFormat
is not correct to format the date unformattedDate
.