JodaFormatter { public Period parsePeriod(String intervalString) { return parse(intervalString, Locale.getDefault()); } JodaFormatter(); Period parse(String intervalString, Locale locale); Period parsePeriod(String intervalString); String formatPeriod(Period period); DateTime parseDateTime(String isoDateTime); String formatDateTime(DateTime dateTime);  }
@Test public void shouldParseIntervalInYear() throws Exception { assertYear(1, new JodaFormatter().parsePeriod("1 year")); assertYear(1, new JodaFormatter().parsePeriod("1 years")); assertYear(2, new JodaFormatter().parsePeriod("2 years")); }
@Test public void shouldParseIntervalInMonth() throws Exception { assertEquals(5, new JodaFormatter().parsePeriod("5 months").getMonths()); assertEquals(5, new JodaFormatter().parsePeriod("5 days").getDays()); assertEquals(5, new JodaFormatter().parsePeriod("5 hours").getHours()); assertEquals(5, new JodaFormatter().parsePeriod("5 minutes").getMinutes()); assertEquals(5, new JodaFormatter().parsePeriod("5 seconds").getSeconds()); }
@Test(expected = ParseException.class) public void shouldFailParsingForInvalidFormat() throws Exception { new JodaFormatter().parsePeriod("five months").getMonths(); }