如何解析来自AppEngine上用Java(安卓)的DateTime的财产? [英] How to parse DateTime property from AppEngine in Java (Android)?

查看:97
本文介绍了如何解析来自AppEngine上用Java(安卓)的DateTime的财产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要解析的时间字符串从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));

这篇关于如何解析来自AppEngine上用Java(安卓)的DateTime的财产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆