2

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?

AdamHurwitz
  • 9,758
  • 10
  • 72
  • 134
MosesA
  • 925
  • 5
  • 27
  • 53

2 Answers2

4

Just use small y instead of Y:

final String TWITTER="EEE, dd MMM yyyy HH:mm:ss ZZZZZ";
Jaqen H'ghar
  • 4,305
  • 2
  • 14
  • 26
2

This is the latest created_at format received from the Twitter response for GET lists/statuses.

"EEE MMM dd HH:mm:ss ZZZZZ yyyy"

AdamHurwitz
  • 9,758
  • 10
  • 72
  • 134