user2325154 user2325154 - 1 month ago 4x
Java Question

Not able to parse UTC date time to EST local time

Getting following exception while parsing UTC date time to EST local time.


Stacktrace:] with root cause
java.text.ParseException: Unparseable date: "2016-09-09T03:00:29Z"
at java.text.DateFormat.parse(

public static String convertUTCDateToEST(String utcDate) throws ParseException {
SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", Locale.US);
Date aDate = inFormat.parse(utcDate);

DateFormat outFormat = new SimpleDateFormat("yyyy-MM-dd HH:MI:SS");
String estDate = outFormat.format(aDate);

return estDate;

Found some similar stuff on SO here java.text.ParseException: Unparseable date "yyyy-MM-dd'T'HH:mm:ss.SSSZ" - SimpleDateFormat and tried solutions proposed there but did not work.


There is a error in the input format. You have specified milli seconds as an input to your format .SSS and then the zone Z.

You have however not passed the milli second option. The following format works

SimpleDateFormat inFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");