我有String 11/08/2013 08:48:10
我使用SimpleDateFormat(“MM / dd / yyyy HH:mm:ss”)
当我解析它时抛出一个异常:不可解析的日期
它出什么问题了 ?
- String result = han.ExecuteUrl("http://"+han.IP+":8015/api/Values/GetLastChange");
- Log.d("Dal","result date time "+result); #result is 11/08/2013 08:48:10
- SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- Date convertedDate = new Date();
- try
- {
- convertedDate = dateFormat.parse(result);
- }
- catch (ParseException e)
- {
- e.printStackTrace();
- }
解决方法
它的工作尝试解析你的日期..
- String dtStart = "11/08/2013 08:48:10";
- SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- try {
- date = format.parse(dtStart);
- System.out.println("Date ->" + date);
- } catch (ParseException e) {
- e.printStackTrace();
- }