2013-05-19 48 views
0

我在Android中使用simple-xml,并按照格式获取日期"2013-05-13+02:00", 我尝试以String格式获取日期,之后我无法在此分析此日期格式!解析日期,SimpleXML,Android

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" 
+0

ü有没有试过我的答案? – Daniel

回答

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; 
    } 
} 
+0

谢谢!这是解决方案! –