Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.text.ParseException: Unparseable date: [duplicate]

Tags:

java

date

android

I'm trying to get Date from String,

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z");
Date date = simpleDateFormat.parse(dateString);

My date string is:

Wed, 02 September 2015 08:27:00 MSK

I'm getting this error:

java.text.ParseException: Unparseable date: "Wed, 02 September 2015 08:27:00 MSK" (at offset 32)

What's wrong? Thx for help.

like image 437
llaerto Avatar asked May 04 '26 06:05

llaerto


1 Answers

I see that you have MSK time. Is your locale English or Russian ? Because if your locale is Russian, September is not a valid month. So, you have 2 options :

  1. Change your locale to English.
  2. Let your locale in Russian, but write the month in Russian.

Fix for changing the locale to English :

SimpleDateFormat simpleDateFormat = new SimpleDateFormat("EEE, d MMM yyyy HH:mm:ss Z", Locale.ENGLISH);
like image 165
Cosmin Avatar answered May 06 '26 20:05

Cosmin