由网友(毛骨悚男,))分享简介:我需要解析的时间字符串从AppEngine上用Java(安卓)的到来。该字符串看起来是这样的: 2011-07-26 17:21:00 + 01:00 。它是一些标准格式?有没有比使用自定义的简单的方法的SimpleDateFormat ?I need to parse DateTime string coming...
我需要解析的时间字符串从AppEngine上用Java(安卓)的到来。该字符串看起来是这样的: 2011-07-26 17:21:00 + 01:00
。它是一些标准格式?有没有比使用自定义的简单的方法的SimpleDateFormat
?
I need to parse DateTime string coming from AppEngine in Java (Android). The string looks like this: 2011-07-26 17:21:00+01:00
. Is it some standard format? Is there simpler way than using custom SimpleDateFormat
?
推荐答案
的SimpleDateFormat
是pretty的简单,只是一个事实,即你的日期字符串是有点过因为最后:
在那里。只需更换:
,并使用以下方式:
SimpleDateFormat
is pretty simple except that for the fact that your date string is a bit off because of the last :
in there. Just replace the :
and use the following pattern:
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:ss:mmZ");
String dateStr = "2011-07-26 17:21:00+0100";
System.out.println(sdf.parse(dateStr));
相关推荐
最新文章