ReportMonth { public LocalDate endOfCurrentReportMonth(LocalDate date) { if (date.getDayOfMonth() > REPORTING_MONTH_END_DAY) { if (date.getMonthOfYear() == DECEMBER) { return new LocalDate(nextYear(date), JANUARY, REPORTING_MONTH_END_DAY); } else { return new LocalDate(date.getYear(), nextMonth(date), REPORTING_MONTH_END_DAY); } } else { return new LocalDate(date.getYear(), date.getMonthOfYear(), REPORTING_MONTH_END_DAY); } }  Date startDateOfReportingYear(); int reportingYear(); LocalDate startDateOfNextReportingMonth(LocalDate date); LocalDate endDateOfReportingMonthGivenStartDate(LocalDate startDate); LocalDate startOfCurrentReportMonth(LocalDate date); LocalDate endOfCurrentReportMonth(LocalDate date); boolean isDateWithinCurrentReportMonth(LocalDate lastReportedDate); int reportingMonth(LocalDate date); int reportingYear(LocalDate date); boolean areDatesBelongToSameReportingMonth(LocalDate date, LocalDate anotherDate);  }
@Test public void shouldCalculateEndDateOfCurrentReportMonth() throws Exception { assertEquals(LocalDate.parse("2013-01-25"), reportMonth.endOfCurrentReportMonth(LocalDate.parse("2012-12-26"))); assertEquals(LocalDate.parse("2013-01-25"), reportMonth.endOfCurrentReportMonth(LocalDate.parse("2012-12-30"))); assertEquals(LocalDate.parse("2013-01-25"), reportMonth.endOfCurrentReportMonth(LocalDate.parse("2013-01-01"))); assertEquals(LocalDate.parse("2013-02-25"), reportMonth.endOfCurrentReportMonth(LocalDate.parse("2013-01-26"))); assertEquals(LocalDate.parse("2013-01-25"), reportMonth.endOfCurrentReportMonth(LocalDate.parse("2013-01-25"))); }