@Test public void testGetFirstDateOfCurrentMonth() throws Exception { assertEquals(LocalDate.parse("2014-08-01"), mWeek.getFirstDateOfCurrentMonth(LocalDate.parse("2014-08-23"))); }
@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 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 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); }
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(); }
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();  }