0

我在Android中使用simple-xml,我得到了以下格式的日期"2013-05-13+02:00",我尝试以字符串格式获取日期,之后我无法以这种格式解析这个日期!

private Date modifyDateLayout(String inputDate){ 
    SimpleDateFormat  format = new SimpleDateFormat("yyyy-MM-dd HH:mm");  
    try {  
        Date date = format.parse(inputDate);  
        Log.i("date: ", date.toString());
        return date;
    } catch (ParseException e) {  
        Log.i("error ParseException : ", e.toString());
        return null;
    }
}

我收到此错误:

java.text.ParseException: Unparseable date: "2013-05-13+02:00"
4

1 回答 1

0

尝试这样做:

private Date modifyDateLayout(String inputDate){ 
    SimpleDateFormat  format = new SimpleDateFormat("yyyy-MM-dd+HH:mm");  
    try {  
        Date date = format.parse(inputDate);  
        Log.i("date: ", date.toString());
        return date;
    } catch (ParseException e) {  
        Log.i("error ParseException : ", e.toString());
        return null;
    }
}
于 2013-05-19T16:03:33.017 回答