@Test public void generateEndDate_DAY() { LocalDate startDate = new LocalDate(2011, 11, 11); LocalDate endDate = utils.generateEndDate(startDate, new Period(1, PeriodUnit.DAY)); assertEquals(new LocalDate(2011, 11, 11), endDate); }
public LocalDate generateEndDate(LocalDate startDate, Period period) { if (period.getUnit().equals(PeriodUnit.DAY)) { return startDate.plusDays(period.getValue()-1); } if (period.getUnit().equals(PeriodUnit.MONTH)) { return startDate.plusMonths(period.getValue()).minusDays(1); } if (period.getUnit().equals(PeriodUnit.YEAR)) { return startDate.plusYears(period.getValue()).minusDays(1); } throw new IllegalArgumentException("Period unit " + period.getUnit() + " not handled"); }
XDateRangeUtils { public LocalDate generateEndDate(LocalDate startDate, Period period) { if (period.getUnit().equals(PeriodUnit.DAY)) { return startDate.plusDays(period.getValue()-1); } if (period.getUnit().equals(PeriodUnit.MONTH)) { return startDate.plusMonths(period.getValue()).minusDays(1); } if (period.getUnit().equals(PeriodUnit.YEAR)) { return startDate.plusYears(period.getValue()).minusDays(1); } throw new IllegalArgumentException("Period unit " + period.getUnit() + " not handled"); } }
XDateRangeUtils { public LocalDate generateEndDate(LocalDate startDate, Period period) { if (period.getUnit().equals(PeriodUnit.DAY)) { return startDate.plusDays(period.getValue()-1); } if (period.getUnit().equals(PeriodUnit.MONTH)) { return startDate.plusMonths(period.getValue()).minusDays(1); } if (period.getUnit().equals(PeriodUnit.YEAR)) { return startDate.plusYears(period.getValue()).minusDays(1); } throw new IllegalArgumentException("Period unit " + period.getUnit() + " not handled"); }  }
XDateRangeUtils { public LocalDate generateEndDate(LocalDate startDate, Period period) { if (period.getUnit().equals(PeriodUnit.DAY)) { return startDate.plusDays(period.getValue()-1); } if (period.getUnit().equals(PeriodUnit.MONTH)) { return startDate.plusMonths(period.getValue()).minusDays(1); } if (period.getUnit().equals(PeriodUnit.YEAR)) { return startDate.plusYears(period.getValue()).minusDays(1); } throw new IllegalArgumentException("Period unit " + period.getUnit() + " not handled"); }  XDateRange getDateRange(XSettings xsettings); LocalDate generateEndDate(LocalDate startDate, Period period); }
XDateRangeUtils { public LocalDate generateEndDate(LocalDate startDate, Period period) { if (period.getUnit().equals(PeriodUnit.DAY)) { return startDate.plusDays(period.getValue()-1); } if (period.getUnit().equals(PeriodUnit.MONTH)) { return startDate.plusMonths(period.getValue()).minusDays(1); } if (period.getUnit().equals(PeriodUnit.YEAR)) { return startDate.plusYears(period.getValue()).minusDays(1); } throw new IllegalArgumentException("Period unit " + period.getUnit() + " not handled"); }  XDateRange getDateRange(XSettings xsettings); LocalDate generateEndDate(LocalDate startDate, Period period);  }