Month extends RangeUnit { @Override public void build() { setSelected(false); mWeeks.clear(); LocalDate date = getFrom().withDayOfWeek(1); for (int i = 0; i == 0 || getTo().compareTo(date) >= 0; i++) { mWeeks.add(new Week(date, getToday(), getMinDate(), getMaxDate())); date = date.plusWeeks(1); } } protected  Month(@NonNull LocalDate date, @NonNull LocalDate today, @Nullable LocalDate minDate,
                    @Nullable LocalDate maxDate); @Override boolean hasNext(); @Override boolean hasPrev(); @Override boolean next(); @Override boolean prev(); @Override int getType(); @Override void deselect(@NonNull LocalDate date); @Override boolean select(@NonNull LocalDate date); @NonNull List<Week> getWeeks(); int getSelectedIndex(); @Override void build();  }
@Test public void testBuild() throws Exception { mMonth.build(); List<Week> weeks = mMonth.getWeeks(); LocalDate base = LocalDate.parse("2014-09-29"); assertEquals(5, weeks.size()); for (int i = 0; i < weeks.size(); i++) { assertEquals(base.plusWeeks(i), weeks.get(i).getFrom()); assertEquals(base.plusWeeks(i).withDayOfWeek(DateTimeConstants.SUNDAY), weeks.get(i).getTo()); } }