This question already has an answer here:
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");
got exception
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"
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");
I think the original Exception is due to
Z
in your format. Per documentation:most likely you meant to use lower case
z
Instead of using
Locale.default
that you and others often don't know which default, you can decide by usinglocale.ENGLISH
because I see your string date is format in English. If you are at other countries, the format will be different.Here is my example code:
The result will be :
date: Wed Oct 16 05:00:00 ICT 2013
. Or you can decide which part of this date to be printed, by using its fields.Hope this help :)
I'm going to assume that
Locale.getDefault()
for you ispl-PL
since you seem to be in Poland.English words in date strings therefore cause an unparseable date.
An appropriate Polish date
String
would be something likeOtherwise, change your
Locale
toLocale.ENGLISH
so that theSimpleDateFormat
object can parseString
dates with English words.