日期格式解析异常 - “EEE MMM dd HH:mm:ss Z yyyy" [英] Date format parse exception - "EEE MMM dd HH:mm:ss Z yyyy"
问题描述
我遇到了日期解析示例日期的问题:
I got problem with date parse example date:
SimpleDateFormat parserSDF=new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.getDefault());
parserSDF.parse("Wed Oct 16 00:00:00 CEST 2013");
出现异常
确切地说,我想将此格式日期解析为 yyyy-MM-dd我试试:
Exacly I want parse this format date to yyyy-MM-dd I try:
SimpleDateFormat parserSDF = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
Date date = parserSDF.parse("Wed Oct 16 00:00:00 CEST 2013");
采取:java.text.ParseException:无法解析的日期:2013 年 10 月 16 日星期三 00:00:00 CEST"
take : java.text.ParseException: Unparseable date: "Wed Oct 16 00:00:00 CEST 2013"
好的,我改为工作:
SimpleDateFormat parserSDF = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzzz yyyy", Locale.ENGLISH);
Date date = parserSDF.parse("Wed Oct 16 00:00:00 CEST 2013");
推荐答案
我将假设 Locale.getDefault()
对你来说是 pl-PL
因为你好像在波兰.
I'm going to assume that Locale.getDefault()
for you is pl-PL
since you seem to be in Poland.
日期字符串中的英语单词因此导致无法解析的日期.
English words in date strings therefore cause an unparseable date.
一个合适的波兰日期 String
类似于
An appropriate Polish date String
would be something like
"Wt paź 16 00:00:00 -0500 2013"
否则,将您的 Locale
更改为 Locale.ENGLISH
以便 SimpleDateFormat
对象可以解析 String
日期英文单词.
Otherwise, change your Locale
to Locale.ENGLISH
so that the SimpleDateFormat
object can parse String
dates with English words.
这篇关于日期格式解析异常 - “EEE MMM dd HH:mm:ss Z yyyy"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!