Week extends RangeUnit { @Nullable @Override LocalDate getFirstDateOfCurrentMonth(@NonNull LocalDate currentMonth) { if (currentMonth != null) { int year = currentMonth.getYear(); int month = currentMonth.getMonthOfYear(); LocalDate date = getFrom(); for (; date.compareTo(getTo()) <= 0; date = date.plusDays(1)) { int fromYear = date.getYear(); int fromMonth = date.getMonthOfYear(); if (year == fromYear && month == fromMonth) { return date; } } } return null; } Week(@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<Day> getDays(); @Override void build();  }
@Test public void testGetFirstDateOfCurrentMonthNull() throws Exception { assertNull(mWeek.getFirstDateOfCurrentMonth(null)); }
@Test public void testGetFirstDateOfCurrentMonthNotIn() throws Exception { assertNull(mWeek.getFirstDateOfCurrentMonth(LocalDate.parse("2014-09-01"))); }
@Test public void testGetFirstDateOfCurrentMonthYear() throws Exception { assertNull(mWeek.getFirstDateOfCurrentMonth(LocalDate.parse("2015-08-01"))); }
@Test public void testGetFirstDateOfCurrentMonth() throws Exception { assertEquals(LocalDate.parse("2014-08-01"), mWeek.getFirstDateOfCurrentMonth(LocalDate.parse("2014-08-23"))); }