androiddatedate-formatdatetime-parsing

java.text.ParseException: Unparseable date: ""


SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US);
try {
    Date date = df.parse("2014-06-10T13:37:17.744Z");
    dateString = android.text.format.DateFormat.format("MMM d, yyyy, h:mm a", date)
            .toString();
} catch (ParseException e) {
    e.printStackTrace();
}

java.text.ParseException: Unparseable date: "2014-06-10T13:37:17.744Z"


Solution

  • you have also milliseconds:

    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ", Locale.US);