This datetime instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
DateMidnight added = dt.plusYears(6); DateMidnight added = dt.plus(Period.years(6)); DateMidnight added = dt.withFieldAdded(DurationFieldType.years(), 6);@param years the amount of years to add, may be negative @return the new datetime plus the increased years @since 1.1
The calculation will do its best to only change the year field retaining the same month of year. However, in certain circumstances, it may be necessary to alter smaller fields. For example, 2008-02-29 plus one year cannot result in 2009-02-29, so the day of month is adjusted to 2009-02-28.
The following three lines are identical in effect:
DateTime added = dt.plusYears(6); DateTime added = dt.plus(Period.years(6)); DateTime added = dt.withFieldAdded(DurationFieldType.years(), 6);
This datetime instance is immutable and unaffected by this method call. @param years the amount of years to add, may be negative @return the new datetime plus the increased years @since 1.1
This LocalDate instance is immutable and unaffected by this method call.
The following three lines are identical in effect:
LocalDate added = dt.plusYears(6); LocalDate added = dt.plus(Period.years(6)); LocalDate added = dt.withFieldAdded(DurationFieldType.years(), 6);@param years the amount of years to add, may be negative @return the new LocalDate plus the increased years
This period instance is immutable and unaffected by this method call. @param years the amount of years to add, may be negative @return the new period with the increased years @throws UnsupportedOperationException if the field is not supported
This method adds the specified amount to the years field in three steps:
For example, 2008-02-29 (leap year) plus one year would result in the invalid date 2009-02-29 (standard year). Instead of returning an invalid result, the last valid day of the month, 2009-02-28, is selected instead.
This instance is immutable and unaffected by this method call. @param yearsToAdd the years to add, may be negative @return a {@code LocalDate} based on this date with the years added, not null @throws DateTimeException if the result exceeds the supported date range
This instance is immutable and unaffected by this method call. @param yearsToAdd the years to add, may be negative @return a {@code Year} based on this year with the period added, not null @throws DateTimeException if the result exceeds the supported year range
This instance is immutable and unaffected by this method call. @param yearsToAdd the years to add, may be negative @return a {@code YearMonth} based on this year-month with the years added, not null @throws DateTimeException if the result exceeds the supported range
This operates on the local time-line, {@link LocalDateTime#plusYears(long) adding years} 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 years the years to add, may be negative @return a {@code ZonedDateTime} based on this date-time with the years added, not null @throws DateTimeException if the result exceeds the supported date range
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|