SimpleDateFormat的 - 无法解析的日期 [英] SimpleDateFormat - Unparseable date
本文介绍了SimpleDateFormat的 - 无法解析的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试字符串转换为日期。
I try to convert String to Date.
下面是我的code:
SimpleDateFormat format = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy");
Date date = format.parse("Sun Apr 08 16:37:00 CEST 2012");
我得到异常:
I get exception:
04-08 13:51:36.536:W / System.err的(8005):java.text.ParseException: 无法解析的日期:孙四月八日16时37分00秒CEST 2012
04-08 13:51:36.536: W/System.err(8005): java.text.ParseException: Unparseable date: "Sun Apr 08 16:37:00 CEST 2012".
格式似乎是确定。我失去了一些东西?
Format seems to be ok. Am I missing something?
感谢。
推荐答案
无论您发布的code不是你的实际code,或者你有一个语言环境的问题。它工作正常的<击>日击>甲骨文的Java 1.6与美国的语言环境。
Either the code you posted is not your actual code, or you have a locale issue. It works fine on Sun Oracle Java 1.6 with a US locale.
更改code到:
SimpleDateFormat format =
new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
这篇关于SimpleDateFormat的 - 无法解析的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文