1

I try to parse string (russian locale) "01 августа 2014, пятница. 20:00 МСК" to java.util.Date. I try this code:

String dateString = "01 августа 2014, пятница. 20:00 МСК"
Locale rusLocale = new Locale.Builder().setLanguage("ru").setScript("Cyrl").build();
String pattern = "dd MMMM yyyy, EEEE. HH:mm z"
Date date = SimpleDateFormat(pattern, rusLocale).parse(dateString)

With month and weekday this code work fine, but when I try to parse string with timezone name МСК I get java.text.ParseException: Unparseable date. When I change MCK to MSK "01 августа 2014, пятница. 20:00 MSK" code also work fine. So we can parse strings month and weekday, but can't do it with timezone or "MCK" is just not valid?

BETEP
  • 15
  • 2
  • possible duplicate of [Java SimpleDatetime parse](http://stackoverflow.com/questions/26076595/java-simpledatetime-parse) – Basil Bourque Sep 28 '14 at 16:02

1 Answers1

0

Try this code. I think it is something relevant with your code.

    String dateString = "17 октябрь 2014, пятница. 20:00";
    Locale rusLocale = new Locale.Builder().setLanguage("ru").setScript("Cyrl").build();
    String pattern = "dd MMMM yyyy, EEEE. HH:mm";
    try {
        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern, rusLocale);
        dateFormat.setTimeZone(TimeZone.getTimeZone("МСК"));  
        Date date = dateFormat.parse(dateString);   
    } catch (ParseException e) {
    ...
Alexey Semenyuk
  • 3,263
  • 2
  • 32
  • 36