-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
什么是例外?你确定这些字符串是正确的吗?评论中的值适合我。 –