The calculation will do its best to only change the day field retaining the same time of day. However, in certain circumstances, typically daylight savings cutover, it may be necessary to alter the time fields.
In spring an hour is typically removed. If subtracting one day results in the time being within the cutover then the time is adjusted to be within summer time. For example, if the cutover is from 01:59 to 03:00 and the result of this method would have been 02:30, then the result will be adjusted to 03:30.
The following three lines are identical in effect:
DateTime subtracted = dt.minusDays(6); DateTime subtracted = dt.minus(Period.days(6)); DateTime subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);
This datetime instance is immutable and unaffected by this method call. @param days the amount of days to subtract, may be negative @return the new datetime minus the increased days @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.minusDays(6); LocalDate subtracted = dt.minus(Period.days(6)); LocalDate subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);@param days the amount of days to subtract, may be negative @return the new LocalDate minus the increased days
This LocalDateTime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDateTime subtracted = dt.minusDays(6); LocalDateTime subtracted = dt.minus(Period.days(6)); LocalDateTime subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);@param days the amount of days to subtract, may be negative @return the new LocalDateTime minus the increased days
This datetime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
YearMonthDay subtracted = dt.minusDays(6); YearMonthDay subtracted = dt.minus(Period.days(6)); YearMonthDay subtracted = dt.withFieldAdded(DurationFieldType.days(), -6);@param days the amount of days to subtract, may be negative @return the new datetime minus the increased days @since 1.1
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.
For example, 2009-01-01 minus one day would result in 2008-12-31.
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
This operates on the local time-line, {@link LocalDateTime#minusDays(long) subtracting days} 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 days the days to subtract, may be negative @return a {@code ZonedDateTime} based on this date-time with the days subtracted, not null @throws DateTimeException if the result exceeds the supported date range
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|