Parsing date in polish locale in Joda?

I have following date:

eg. String rawDate = "pon, 17 lis 2014, 15:51:12";

and I would like to parse it.

I call:

DateTime time = new DateTimeFormatterBuilder()
                    .append(DateTimeFormat.forPattern("EEE, dd MMM yyyy, HH:mm:ss")
                            .getParser())
                    .toFormatter().withLocale(new Locale("pl")).parseDateTime(rawDate);

But I get:

java.lang.IllegalArgumentException: Invalid format: "pon, 17 lis 2014, 15:51:12"

Jon Skeet
people
quotationmark

Apparently Joda Time (or Java) treats the abbreviated form of poniedziaƂek is pn, not pon - so this code works (and is slightly simpler than yours):

import org.joda.time.*;
import org.joda.time.format.*;
import java.util.*;

public class Test {
    public static void main(String[] args) throws Exception {
        String rawDate = "pn, 17 lis 2014, 15:51:12";
        DateTimeFormatter parser = DateTimeFormat
            .forPattern("EEEE, dd MMM yyyy, HH:mm:ss")
            .withLocale(new Locale("pl"));
        DateTime time = parser.parseDateTime(rawDate);
        System.out.println(time);
    }
}

If you can't change your input, perhaps you can change the symbols associated with the locale?

people

See more on this question at Stackoverflow