日期格式解析异常 - “EEE MMM dd HH:mm:ss Z yyyy” [英] Date format parse exception - "EEE MMM dd HH:mm:ss Z yyyy"

查看:1793
本文介绍了日期格式解析异常 - “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");

有异常

Exacly我想解析这个格式日期到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");

take:
java.text.ParseException:Unparseable date:Wed Oct 16 00: 00:00 CEST 2013

take : java.text.ParseException: Unparseable date: "Wed Oct 16 00:00:00 CEST 2013"

确定我更改并正常工作:

OK I change to and works :

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 your 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 object可以用英文单词解析 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屋!

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