@Override protected void buildDayViews( final Collection<DayView> dayViews, final LocalDate calendar) { LocalDate temp = calendar; for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) { addDayView(dayViews, temp); temp = temp.plusDays(1); } }
@Override protected void buildDayViews( final Collection<DayView> dayViews, final LocalDate calendar) { LocalDate temp = calendar; for (int r = 0; r < DEFAULT_MAX_WEEKS; r++) { for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) { addDayView(dayViews, temp); temp = temp.plusDays(1); } } }
@Override protected List<CalendarDay> doInBackground(@NonNull Void... voids) { try { Thread.sleep(2000); } catch (InterruptedException e) { e.printStackTrace(); } LocalDate temp = LocalDate.now().minusMonths(2); final ArrayList<CalendarDay> dates = new ArrayList<>(); for (int i = 0; i < 30; i++) { final CalendarDay day = CalendarDay.from(temp); dates.add(day); temp = temp.plusDays(5); } return dates; }
private void buildWeekDays(LocalDate calendar) { LocalDate local = calendar; for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) { WeekDayView weekDayView = new WeekDayView(getContext(), local.getDayOfWeek()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { weekDayView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); } weekDayViews.add(weekDayView); addView(weekDayView); local = local.plusDays(1); } }
/** * Clear the previous selection, select the range of days from first to last, and finally * invalidate. First day should be before last day, otherwise the selection won't happen. * * @param first The first day of the range. * @param last The last day in the range. * @see CalendarPagerAdapter#setDateSelected(CalendarDay, boolean) */ public void selectRange(final CalendarDay first, final CalendarDay last) { selectedDates.clear(); // Copy to start from the first day and increment LocalDate temp = LocalDate.of(first.getYear(), first.getMonth(), first.getDay()); // for comparison final LocalDate end = last.getDate(); while( temp.isBefore(end) || temp.equals(end) ) { selectedDates.add(CalendarDay.from(temp)); temp = temp.plusDays(1); } invalidateSelectedDates(); }
protected LocalDate resetAndGetWorkingCalendar() { final TemporalField firstDayOfWeek = WeekFields.of(this.firstDayOfWeek, 1).dayOfWeek(); final LocalDate temp = getFirstViewDay().getDate().with(firstDayOfWeek, 1); int dow = temp.getDayOfWeek().getValue(); int delta = getFirstDayOfWeek().getValue() - dow; //If the delta is positive, we want to remove a week boolean removeRow = showOtherMonths(showOtherDates) ? delta >= 0 : delta > 0; if (removeRow) { delta -= DEFAULT_DAYS_IN_WEEK; } return temp.plusDays(delta); }
CalendarDay lastVisibleCalendarDay = CalendarDay.from(lastVisibleCalendar.plusDays(1)); if (currentlySelectedDate.equals(calendarDayToShow) || (currentlySelectedDate.isAfter(calendarDayToShow) && currentlySelectedDate.isBefore( CalendarDay lastVisibleCalendarDay = CalendarDay.from(lastVisibleCalendar.plusDays(6)); if (currentlySelectedDate != null && (currentlySelectedDate.equals(calendarDayToShow) || currentlySelectedDate.equals(
/** * Returns a copy of this {@code LocalDate} with the specified number of days subtracted. * <p> * This method subtracts the specified amount from the days field decrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2009-01-01 minus one day would result in 2008-12-31. * <p> * This instance is immutable and unaffected by this method call. * * @param daysToSubtract the days to subtract, may be negative * @return a {@code LocalDate} based on this date with the days subtracted, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDate minusDays(long daysToSubtract) { return (daysToSubtract == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-daysToSubtract)); }
/** * Returns a copy of this {@code LocalDate} with the specified number of days subtracted. * <p> * This method subtracts the specified amount from the days field decrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2009-01-01 minus one day would result in 2008-12-31. * <p> * This instance is immutable and unaffected by this method call. * * @param daysToSubtract the days to subtract, may be negative * @return a {@code LocalDate} based on this date with the days subtracted, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDate minusDays(long daysToSubtract) { return (daysToSubtract == Long.MIN_VALUE ? plusDays(Long.MAX_VALUE).plusDays(1) : plusDays(-daysToSubtract)); }
@Override ThaiBuddhistDate plusDays(long days) { return with(isoDate.plusDays(days)); }
@Override MinguoDate plusDays(long days) { return with(isoDate.plusDays(days)); }
@Override MinguoDate plusDays(long days) { return with(isoDate.plusDays(days)); }
@Override JapaneseDate plusDays(long days) { return with(isoDate.plusDays(days)); }
@Override ThaiBuddhistDate plusDays(long days) { return with(isoDate.plusDays(days)); }
@Override JapaneseDate plusDays(long days) { return with(isoDate.plusDays(days)); }
/** * Returns a copy of this {@code LocalDate} with the specified period in weeks added. * <p> * This method adds the specified amount in weeks to the days field incrementing * the month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2008-12-31 plus one week would result in 2009-01-07. * <p> * This instance is immutable and unaffected by this method call. * * @param weeksToAdd the weeks to add, may be negative * @return a {@code LocalDate} based on this date with the weeks added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDate plusWeeks(long weeksToAdd) { return plusDays(Jdk8Methods.safeMultiply(weeksToAdd, 7)); }
/** * Returns a copy of this {@code LocalDateTime} with the specified period in days added. * <p> * This method adds the specified amount to the days field incrementing the * month and year fields as necessary to ensure the result remains valid. * The result is only invalid if the maximum/minimum year is exceeded. * <p> * For example, 2008-12-31 plus one day would result in 2009-01-01. * <p> * This instance is immutable and unaffected by this method call. * * @param days the days to add, may be negative * @return a {@code LocalDateTime} based on this date-time with the days added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDateTime plusDays(long days) { LocalDate newDate = date.plusDays(days); return with(newDate, time); }
@SuppressWarnings("unchecked") @Override public <R extends Temporal> R adjustInto(R temporal, long newValue) { if (isSupportedBy(temporal) == false) { throw new UnsupportedTemporalTypeException("Unsupported field: WeekBasedYear"); } int newWby = range().checkValidIntValue(newValue, WEEK_BASED_YEAR); // strict check LocalDate date = LocalDate.from(temporal); int dow = date.get(DAY_OF_WEEK); int week = getWeek(date); if (week == 53 && getWeekRange(newWby) == 52) { week = 52; } LocalDate resolved = LocalDate.of(newWby, 1, 4); // 4th is guaranteed to be in week one int days = (dow - resolved.get(DAY_OF_WEEK)) + ((week - 1) * 7); resolved = resolved.plusDays(days); return (R) temporal.with(resolved); } };
/** * Converts this to a transition. * * @param standardOffset the active standard offset, not null * @param savingsBeforeSecs the active savings in seconds * @return the transition, not null */ ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) { // copy of code in ZoneOffsetTransitionRule to avoid infinite loop LocalDate date = toLocalDate(); date = deduplicate(date); LocalDateTime ldt = deduplicate(LocalDateTime.of(date.plusDays(adjustDays), time)); ZoneOffset wallOffset = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs)); LocalDateTime dt = deduplicate(timeDefinition.createDateTime(ldt, standardOffset, wallOffset)); ZoneOffset offsetAfter = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs)); return new ZoneOffsetTransition(dt, wallOffset, offsetAfter); }
/** * Converts this to a transition. * * @param standardOffset the active standard offset, not null * @param savingsBeforeSecs the active savings in seconds * @return the transition, not null */ ZoneOffsetTransition toTransition(ZoneOffset standardOffset, int savingsBeforeSecs) { // copy of code in ZoneOffsetTransitionRule to avoid infinite loop LocalDate date = toLocalDate(); date = deduplicate(date); LocalDateTime ldt = deduplicate(LocalDateTime.of(date.plusDays(adjustDays), time)); ZoneOffset wallOffset = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingsBeforeSecs)); LocalDateTime dt = deduplicate(timeDefinition.createDateTime(ldt, standardOffset, wallOffset)); ZoneOffset offsetAfter = deduplicate(ZoneOffset.ofTotalSeconds(standardOffset.getTotalSeconds() + savingAmountSecs)); return new ZoneOffsetTransition(dt, wallOffset, offsetAfter); }