This datetime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
DateMidnight subtracted = dt.minusMonths(6); DateMidnight subtracted = dt.minus(Period.months(6)); DateMidnight subtracted = dt.withFieldAdded(DurationFieldType.months(), -6);@param months the amount of months to subtract, may be negative @return the new datetime minus the increased months @since 1.1
The calculation will do its best to only change the month field retaining the same day of month. However, in certain circumstances, it may be necessary to alter smaller fields. For example, 2007-05-31 minus one month cannot result in 2007-04-31, so the day of month is adjusted to 2007-04-30.
The following three lines are identical in effect:
DateTime subtracted = dt.minusMonths(6); DateTime subtracted = dt.minus(Period.months(6)); DateTime subtracted = dt.withFieldAdded(DurationFieldType.months(), -6);
This datetime instance is immutable and unaffected by this method call. @param months the amount of months to subtract, may be negative @return the new datetime minus the increased months @since 1.1
This LocalDate instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDate subtracted = dt.minusMonths(6); LocalDate subtracted = dt.minus(Period.months(6)); LocalDate subtracted = dt.withFieldAdded(DurationFieldType.months(), -6);@param months the amount of months to subtract, may be negative @return the new LocalDate minus the increased months
This datetime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
YearMonthDay subtracted = dt.minusMonths(6); YearMonthDay subtracted = dt.minus(Period.months(6)); YearMonthDay subtracted = dt.withFieldAdded(DurationFieldType.months(), -6);@param months the amount of months to subtract, may be negative @return the new datetime minus the increased months @since 1.1
This method subtracts the specified amount from the months field in three steps:
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.
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
This instance is immutable and unaffected by this method call. @param monthsToSubtract the months to subtract, may be negative @return a {@code YearMonth} based on this year-month with the months subtracted, not null @throws DateTimeException if the result exceeds the supported range
This operates on the local time-line, {@link LocalDateTime#minusMonths(long) subtracting months} to the local date-time.This is then converted back to a {@code ZonedDateTime}, using the zone ID to obtain the offset.
When converting back to {@code ZonedDateTime}, if the local date-time is in an overlap, then the offset will be retained if possible, otherwise the earlier offset will be used. If in a gap, the local date-time will be adjusted forward by the length of the gap.
This instance is immutable and unaffected by this method call. @param months the months to subtract, may be negative @return a {@code ZonedDateTime} based on this date-time with the months subtracted, not null @throws DateTimeException if the result exceeds the supported date range
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|