1

我正在尝试解析“updated_time”并尝试将其转换为 Date() 对象。但我得到以下异常。

java.text.ParseException: Unparseable date: "2015-10-11T07:21:14+0000"  

这是我的代码。

private Date convertStringToDate(String createdAt) {
    Date convertedDate = new Date();
    try {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        convertedDate = formatter.parse(createdAt);
    } catch (ParseException e) {
        Log.e(TAG, "parse exception while converting string to date for facebook : "+e.toString());
    }
    return convertedDate;
}  

我用谷歌搜索但没有找到那么多..

4

1 回答 1

1

Z是一个时区,在您的日期格式中,您已经对其进行了转义:'Z'. 只需尝试以下日期格式:

"yyyy-MM-dd'T'HH:mm:ssZ"
于 2015-10-15T09:32:46.920 回答