2013-05-19 50 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

謝謝!這是解決方案! –