Parsing a Twitter date with Joda Time

date-parsing, java, jodatime, twitter

Solution

Although you've said you've used a single `Z` in the format pattern, this works:

DateTimeFormatter format = 
    DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss Z").withLocale(Locale.ENGLISH);
DateTime dateTime = format.parseDateTime("Wed, 27 Mar 2013 15:12:14 +0000");

When parsing this format a single `Z` timezone character will suffice, 4 is invalid:

Z time zone offset/id zone -0800; -08:00; America/Los_Angeles

For more see the javadoc

Problem

Twitter gives me a date such as "Wed, 27 Mar 2013 15:12:14 +0000". I'm trying to parse it with: ``` DateTimeFormat.forPattern("EEE, dd MMM yyyy HH:mm:ss ZZZZZ").withLocale(Locale.ENGLISH); ``` But it fails: ``` Invalid format: "Wed, 03 Apr 2013 10:35:35 +0000" is malformed at "+0000" ``` I've tried replacing `ZZZZZ` with `z`, `Z`, and `ZZZ`, but no change. Can these dates be parsed this way?

Original source