-2
我從webservice獲取日期時間,實際上是從sqlserver數據庫中提取數據,問題是當我嘗試將字符串轉換爲日期時出現分析異常:解析時出現異常日期
這裏是我的代碼:
String tschedule = json.getString("ScheduledFor");
String tduration = json.getString("Duration");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
SimpleDateFormat dateFormat1 = new SimpleDateFormat("HH:mm:ss");
Date schedule = new Date();
Date duration = new Date();
try
{
schedule = dateFormat.parse(tschedule); //exception here, tschedule="2013-04-12T11:25:26.703"
duration = dateFormat1.parse(tduration);//or exception here, tduration="03:10:00"
}
catch(Exception ex)
{
Log.e("MEETINGS SERVICE", "Parse exception: " + ex.getMessage());
}
UPDATE: logcat的ouptut: 04-18 18:54:48.690:E /會議服務(8601):DateParse異常:無法解析日期:2013-04- 12T11:25:26.703
請評論爲什麼downvoting – Daniel
什麼是例外?你確定這些字符串是正確的嗎?評論中的值適合我。 –