// Spent 2 days fighting with dates: I'm giving it up on it! :( public void IGNORED_test_parse_twitter_dates_with_timezone() { String sampleDate = "Sun, 10 Oct 2010 20:56:58 +0002"; try { Date tweetDate = Dates.fromTweeterString(sampleDate); Calendar tweetCalendar = Calendar.getInstance(); tweetCalendar.setTime(tweetDate); assertEquals(2, tweetCalendar.get(Calendar.ZONE_OFFSET)); } catch (RuntimeException e) { e.printStackTrace(); fail("Date Parse Error"); } }
public void test_parse_twitter_dates() { String sampleDate = "Sun, 10 Oct 2010 20:56:58 +0001"; try { Date tweetDate = Dates.fromTweeterString(sampleDate); Calendar tweetCalendar = Calendar.getInstance(); tweetCalendar.setTime(tweetDate); assertEquals(2010, tweetCalendar.get(Calendar.YEAR)); assertEquals(Calendar.SUNDAY, tweetCalendar.get(Calendar.DAY_OF_WEEK)); assertEquals(Calendar.OCTOBER, tweetCalendar.get(Calendar.MONTH)); assertEquals(20, tweetCalendar.get(Calendar.HOUR_OF_DAY)); assertEquals(56, tweetCalendar.get(Calendar.MINUTE)); } catch (RuntimeException e) { e.printStackTrace(); fail("Date Parse Error"); } }