/** * Returns a copy of this date-time with the specified period subtracted. * <p> * This method returns a new date-time based on this date-time with the specified period subtracted. * This can be used to subtract any period that is defined by a unit, for example to subtract years, months or days. * The unit is responsible for the details of the calculation, including the resolution * of any edge cases in the calculation. * <p> * This instance is immutable and unaffected by this method call. * * @param amountToSubtract the amount of the unit to subtract from the result, may be negative * @param unit the unit of the period to subtract, not null * @return a {@code LocalDateTime} based on this date-time with the specified period subtracted, not null * @throws DateTimeException if the unit cannot be added to this type */ @Override public LocalDateTime minus(long amountToSubtract, TemporalUnit unit) { return (amountToSubtract == Long.MIN_VALUE ? plus(Long.MAX_VALUE, unit).plus(1, unit) : plus(-amountToSubtract, unit)); }
/** * Returns a copy of this date-time with the specified period subtracted. * <p> * This method returns a new date-time based on this date-time with the specified period subtracted. * This can be used to subtract any period that is defined by a unit, for example to subtract years, months or days. * The unit is responsible for the details of the calculation, including the resolution * of any edge cases in the calculation. * <p> * This instance is immutable and unaffected by this method call. * * @param amountToSubtract the amount of the unit to subtract from the result, may be negative * @param unit the unit of the period to subtract, not null * @return a {@code LocalDateTime} based on this date-time with the specified period subtracted, not null * @throws DateTimeException if the unit cannot be added to this type */ @Override public LocalDateTime minus(long amountToSubtract, TemporalUnit unit) { return (amountToSubtract == Long.MIN_VALUE ? plus(Long.MAX_VALUE, unit).plus(1, unit) : plus(-amountToSubtract, unit)); }
/** * Returns a copy of this date-time with the specified period added. * <p> * This method returns a new date-time based on this date-time with the specified period added. * This can be used to add any period that is defined by a unit, for example to add years, months or days. * The unit is responsible for the details of the calculation, including the resolution * of any edge cases in the calculation. * The offset is not part of the calculation and will be unchanged in the result. * <p> * This instance is immutable and unaffected by this method call. * * @param amountToAdd the amount of the unit to add to the result, may be negative * @param unit the unit of the period to add, not null * @return an {@code OffsetDateTime} based on this date-time with the specified period added, not null * @throws DateTimeException if the unit cannot be added to this type */ @Override public OffsetDateTime plus(long amountToAdd, TemporalUnit unit) { if (unit instanceof ChronoUnit) { return with(dateTime.plus(amountToAdd, unit), offset); } return unit.addTo(this, amountToAdd); }
/** * Returns a copy of this date-time with the specified period added. * <p> * This method returns a new date-time based on this date-time with the specified period added. * This can be used to add any period that is defined by a unit, for example to add years, months or days. * The unit is responsible for the details of the calculation, including the resolution * of any edge cases in the calculation. * The offset is not part of the calculation and will be unchanged in the result. * <p> * This instance is immutable and unaffected by this method call. * * @param amountToAdd the amount of the unit to add to the result, may be negative * @param unit the unit of the period to add, not null * @return an {@code OffsetDateTime} based on this date-time with the specified period added, not null * @throws DateTimeException if the unit cannot be added to this type */ @Override public OffsetDateTime plus(long amountToAdd, TemporalUnit unit) { if (unit instanceof ChronoUnit) { return with(dateTime.plus(amountToAdd, unit), offset); } return unit.addTo(this, amountToAdd); }
}while((ldt = ldt.plus(org.threeten.bp.Period.ofWeeks(1))).getMonth() == month);