Search code examples
javaandroiddatetimetwitter

Java- Parsing Twitter's created_at String


So I call this method:

System.out.println(getTwitterDate("Thu, 3 Jan 2010 18:26:07 +0000").getMonth());

And I keep getting 11 for every month I use.

I'm doing this in the getTwitterDate:

final String TWITTER="EEE, dd MMM YYYY HH:mm:ss ZZZZZ";
SimpleDateFormat sf = new SimpleDateFormat(TWITTER);
return sf.parse(date);

I'm going by this https://stackoverflow.com/a/4522095/1193534 but removed the sf.lenient part.

What am I doing wrong?


Solution

  • Just use small y instead of Y:

    final String TWITTER="EEE, dd MMM yyyy HH:mm:ss ZZZZZ";