解析日期的android [英] Parse date in android

查看:149
本文介绍了解析日期的android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下的code到填写Flash日期

I have the following code to pase a date

DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss", Locale.getDefault());
Date _pubDate =  df.parse(_pubDateE.getFirstChild().getNodeValue());

不过,我得到这个错误:

But I get this error:

java.text.ParseException:无法解析的日期:星期五,2011 8月12日15点34分47秒CEST

java.text.ParseException: Unparseable date: "Fri, 12 Aug 2011 15:34:47 CEST"

什么是错的?

推荐答案

您错过了日期格式在年底的时区,在你的异常消息,在CEST的一部分。 您的code

You're missing the timezone in the date format at the end, in your exception message, the "CEST" part. Your code

DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss", Locale.getDefault());

DateFormat df = new SimpleDateFormat("EEE, dd MMM yyyy kk:mm:ss z", Locale.getDefault());

您可能需要阅读的SimpleDateFormat

编辑 在此页面的底部,该时区格式更克利解释 更清晰的时区格式

Edit At the bottom of this page, the timezone format is more cleary explained Clearer Timezone format

这篇关于解析日期的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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