@Override public CalendarDay getItem(final int position) { return CalendarDay.from(min.getDate().plusMonths(position)); } }
public void nextMonth() { mCal = mCal.plusMonths(1); }
/** * Returns a copy of this {@code LocalDate} with the specified period in months subtracted. * <p> * This method subtracts the specified amount from the months field in three steps: * <ol> * <li>Subtract the input months to the month-of-year field</li> * <li>Check if the resulting date would be invalid</li> * <li>Adjust the day-of-month to the last valid day if necessary</li> * </ol> * <p> * For example, 2007-03-31 minus one month would result in the invalid date * 2007-02-31. Instead of returning an invalid result, the last valid day * of the month, 2007-02-28, is selected instead. * <p> * This instance is immutable and unaffected by this method call. * * @param monthsToSubtract the months to subtract, may be negative * @return a {@code LocalDate} based on this date with the months subtracted, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDate minusMonths(long monthsToSubtract) { return (monthsToSubtract == Long.MIN_VALUE ? plusMonths(Long.MAX_VALUE).plusMonths(1) : plusMonths(-monthsToSubtract)); }
/** * Returns a copy of this {@code LocalDate} with the specified period in months subtracted. * <p> * This method subtracts the specified amount from the months field in three steps: * <ol> * <li>Subtract the input months to the month-of-year field</li> * <li>Check if the resulting date would be invalid</li> * <li>Adjust the day-of-month to the last valid day if necessary</li> * </ol> * <p> * For example, 2007-03-31 minus one month would result in the invalid date * 2007-02-31. Instead of returning an invalid result, the last valid day * of the month, 2007-02-28, is selected instead. * <p> * This instance is immutable and unaffected by this method call. * * @param monthsToSubtract the months to subtract, may be negative * @return a {@code LocalDate} based on this date with the months subtracted, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDate minusMonths(long monthsToSubtract) { return (monthsToSubtract == Long.MIN_VALUE ? plusMonths(Long.MAX_VALUE).plusMonths(1) : plusMonths(-monthsToSubtract)); }
@Override ThaiBuddhistDate plusMonths(long months) { return with(isoDate.plusMonths(months)); }
@Override MinguoDate plusMonths(long months) { return with(isoDate.plusMonths(months)); }
@Override MinguoDate plusMonths(long months) { return with(isoDate.plusMonths(months)); }
@Override JapaneseDate plusMonths(long months) { return with(isoDate.plusMonths(months)); }
@Override JapaneseDate plusMonths(long months) { return with(isoDate.plusMonths(months)); }
@Override ThaiBuddhistDate plusMonths(long months) { return with(isoDate.plusMonths(months)); }
/** * Returns a copy of this {@code LocalDateTime} with the specified period in months added. * <p> * This method adds the specified amount to the months field in three steps: * <ol> * <li>Add the input months to the month-of-year field</li> * <li>Check if the resulting date would be invalid</li> * <li>Adjust the day-of-month to the last valid day if necessary</li> * </ol> * <p> * For example, 2007-03-31 plus one month would result in the invalid date * 2007-04-31. Instead of returning an invalid result, the last valid day * of the month, 2007-04-30, is selected instead. * <p> * This instance is immutable and unaffected by this method call. * * @param months the months to add, may be negative * @return a {@code LocalDateTime} based on this date-time with the months added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDateTime plusMonths(long months) { LocalDate newDate = date.plusMonths(months); return with(newDate, time); }
/** * Returns a copy of this {@code LocalDateTime} with the specified period in months added. * <p> * This method adds the specified amount to the months field in three steps: * <ol> * <li>Add the input months to the month-of-year field</li> * <li>Check if the resulting date would be invalid</li> * <li>Adjust the day-of-month to the last valid day if necessary</li> * </ol> * <p> * For example, 2007-03-31 plus one month would result in the invalid date * 2007-04-31. Instead of returning an invalid result, the last valid day * of the month, 2007-04-30, is selected instead. * <p> * This instance is immutable and unaffected by this method call. * * @param months the months to add, may be negative * @return a {@code LocalDateTime} based on this date-time with the months added, not null * @throws DateTimeException if the result exceeds the supported date range */ public LocalDateTime plusMonths(long months) { LocalDate newDate = date.plusMonths(months); return with(newDate, time); }
long qoy = qoyLong; date = LocalDate.of(y, 1, 1); date = date.plusMonths(Jdk8Methods.safeMultiply(Jdk8Methods.safeSubtract(qoy, 1), 3)); date = date.plusDays(Jdk8Methods.safeSubtract(doq, 1)); } else {
long qoy = qoyLong; date = LocalDate.of(y, 1, 1); date = date.plusMonths(Jdk8Methods.safeMultiply(Jdk8Methods.safeSubtract(qoy, 1), 3)); date = date.plusDays(Jdk8Methods.safeSubtract(doq, 1)); } else {
long months = Jdk8Methods.safeSubtract(moy, 1); long days = Jdk8Methods.safeSubtract(dom, 1); return LocalDate.of(y, 1, 1).plusMonths(months).plusDays(days); } else if (resolverStyle == ResolverStyle.SMART){ DAY_OF_MONTH.checkValidValue(dom); long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); long days = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_DAY_OF_WEEK_IN_MONTH), 1); return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days); long weeks = Jdk8Methods.safeSubtract(fieldValues.remove(ALIGNED_WEEK_OF_MONTH), 1); long days = Jdk8Methods.safeSubtract(fieldValues.remove(DAY_OF_WEEK), 1); return LocalDate.of(y, 1, 1).plusMonths(months).plusWeeks(weeks).plusDays(days);
if (totalMonths > 0 && days < 0) { totalMonths--; LocalDate calcDate = this.plusMonths(totalMonths); days = (int) (end.toEpochDay() - calcDate.toEpochDay()); // safe } else if (totalMonths < 0 && days > 0) {
if (totalMonths > 0 && days < 0) { totalMonths--; LocalDate calcDate = this.plusMonths(totalMonths); days = (int) (end.toEpochDay() - calcDate.toEpochDay()); // safe } else if (totalMonths < 0 && days > 0) {
case DAYS: return plusDays(amountToAdd); case WEEKS: return plusWeeks(amountToAdd); case MONTHS: return plusMonths(amountToAdd); case YEARS: return plusYears(amountToAdd); case DECADES: return plusYears(Jdk8Methods.safeMultiply(amountToAdd, 10));
case DAYS: return plusDays(amountToAdd); case WEEKS: return plusWeeks(amountToAdd); case MONTHS: return plusMonths(amountToAdd); case YEARS: return plusYears(amountToAdd); case DECADES: return plusYears(Jdk8Methods.safeMultiply(amountToAdd, 10));
case ALIGNED_WEEK_OF_YEAR: return plusWeeks(newValue - getLong(ALIGNED_WEEK_OF_YEAR)); case MONTH_OF_YEAR: return withMonth((int) newValue); case PROLEPTIC_MONTH: return plusMonths(newValue - getLong(PROLEPTIC_MONTH)); case YEAR_OF_ERA: return withYear((int) (year >= 1 ? newValue : 1 - newValue)); case YEAR: return withYear((int) newValue);