@Override public int indexOf(final CalendarDay day) { return (int) Period .between(min.getDate().withDayOfMonth(1), day.getDate().withDayOfMonth(1)) .toTotalMonths(); }
private int getWeekCountBasedOnMode() { int weekCount = calendarMode.visibleWeeksCount; final boolean isInMonthsMode = calendarMode.equals(CalendarMode.MONTHS); if (isInMonthsMode && mDynamicHeightEnabled && adapter != null && pager != null) { final LocalDate cal = adapter.getItem(pager.getCurrentItem()).getDate(); final LocalDate tempLastDay = cal.withDayOfMonth(cal.lengthOfMonth()); weekCount = tempLastDay.get(WeekFields.of(firstDayOfWeek, 1).weekOfMonth()); } return showWeekDays ? weekCount + DAY_NAMES_ROW : weekCount; }
/** * Returns a copy of this {@code LocalDateTime} with the day-of-month altered. * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * The time does not affect the calculation and will be the same in the result. * <p> * This instance is immutable and unaffected by this method call. * * @param dayOfMonth the day-of-month to set in the result, from 1 to 28-31 * @return a {@code LocalDateTime} based on this date-time with the requested day, not null * @throws DateTimeException if the day-of-month value is invalid * @throws DateTimeException if the day-of-month is invalid for the month-year */ public LocalDateTime withDayOfMonth(int dayOfMonth) { return with(date.withDayOfMonth(dayOfMonth), time); }
/** * Returns a copy of this {@code LocalDateTime} with the day-of-month altered. * If the resulting {@code LocalDateTime} is invalid, an exception is thrown. * The time does not affect the calculation and will be the same in the result. * <p> * This instance is immutable and unaffected by this method call. * * @param dayOfMonth the day-of-month to set in the result, from 1 to 28-31 * @return a {@code LocalDateTime} based on this date-time with the requested day, not null * @throws DateTimeException if the day-of-month value is invalid * @throws DateTimeException if the day-of-month is invalid for the month-year */ public LocalDateTime withDayOfMonth(int dayOfMonth) { return with(date.withDayOfMonth(dayOfMonth), time); }
public CalendarAdapter(Context context) { this.mCal = LocalDate.now().withDayOfMonth(1); mInflater = LayoutInflater.from(context); refresh(); }
public void onItemClicked(View view, LocalDate day) { select(day); LocalDate cal = mAdapter.getCalendar(); int newYear = day.getYear(); int newMonth = day.getMonthValue() - 1; int oldYear = cal.getYear(); int oldMonth = cal.getMonthValue(); if (newMonth != oldMonth) { LocalDate d = day.withDayOfMonth(1); mAdapter.setDate(d); if (newYear > oldYear || newMonth > oldMonth) { mCurrentWeekIndex = 0; } if (newYear < oldYear || newMonth < oldMonth) { mCurrentWeekIndex = -1; } if (mListener != null) { mListener.onMonthChange(); } reload(); } if (mListener != null) { mListener.onItemClick(view); } }
case ALIGNED_DAY_OF_WEEK_IN_MONTH: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH)); case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR)); case DAY_OF_MONTH: return withDayOfMonth((int) newValue); case DAY_OF_YEAR: return withDayOfYear((int) newValue); case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);
case ALIGNED_DAY_OF_WEEK_IN_MONTH: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_MONTH)); case ALIGNED_DAY_OF_WEEK_IN_YEAR: return plusDays(newValue - getLong(ALIGNED_DAY_OF_WEEK_IN_YEAR)); case DAY_OF_MONTH: return withDayOfMonth((int) newValue); case DAY_OF_YEAR: return withDayOfYear((int) newValue); case EPOCH_DAY: return LocalDate.ofEpochDay(newValue);