Java Code Examples for java.time.temporal.TemporalAmount#addTo()

The following examples show how to use java.time.temporal.TemporalAmount#addTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocalDateTime.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns a {@code LocalDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDateTime plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return with(date.plus(periodToAdd), time);
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDateTime) amountToAdd.addTo(this);
}
 
Example 2
Source File: LocalDateTime.java    From Java8CN with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns a {@code LocalDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDateTime plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return with(date.plus(periodToAdd), time);
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDateTime) amountToAdd.addTo(this);
}
 
Example 3
Source File: ZonedDateTime.java    From jdk8u-jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns a {@code ZonedDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code ZonedDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public ZonedDateTime plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return resolveLocal(dateTime.plus(periodToAdd));
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (ZonedDateTime) amountToAdd.addTo(this);
}
 
Example 4
Source File: LocalDateTime.java    From jdk8u_jdk with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns a {@code LocalDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDateTime plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return with(date.plus(periodToAdd), time);
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDateTime) amountToAdd.addTo(this);
}
 
Example 5
Source File: LocalDate.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a copy of this date with the specified amount added.
 * <p>
 * This returns a {@code LocalDate}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDate} based on this date with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDate plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return plusMonths(periodToAdd.toTotalMonths()).plusDays(periodToAdd.getDays());
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDate) amountToAdd.addTo(this);
}
 
Example 6
Source File: LocalDateTime.java    From openjdk-8 with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns a {@code LocalDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDateTime plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return with(date.plus(periodToAdd), time);
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDateTime) amountToAdd.addTo(this);
}
 
Example 7
Source File: LocalDate.java    From JDKSourceCode1.8 with MIT License 3 votes vote down vote up
/**
 * Returns a copy of this date with the specified amount added.
 * <p>
 * This returns a {@code LocalDate}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDate} based on this date with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDate plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return plusMonths(periodToAdd.toTotalMonths()).plusDays(periodToAdd.getDays());
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDate) amountToAdd.addTo(this);
}
 
Example 8
Source File: LocalDateTime.java    From Bytecoder with Apache License 2.0 3 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns a {@code LocalDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDateTime plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return with(date.plus(periodToAdd), time);
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDateTime) amountToAdd.addTo(this);
}
 
Example 9
Source File: LocalDateTime.java    From hottub with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns a {@code LocalDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDateTime plus(TemporalAmount amountToAdd) {
    if (amountToAdd instanceof Period) {
        Period periodToAdd = (Period) amountToAdd;
        return with(date.plus(periodToAdd), time);
    }
    Objects.requireNonNull(amountToAdd, "amountToAdd");
    return (LocalDateTime) amountToAdd.addTo(this);
}
 
Example 10
Source File: Instant.java    From jdk8u60 with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a copy of this instant with the specified amount added.
 * <p>
 * This returns an {@code Instant}, based on this one, with the specified amount added.
 * The amount is typically {@link Duration} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return an {@code Instant} based on this instant with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Instant plus(TemporalAmount amountToAdd) {
    return (Instant) amountToAdd.addTo(this);
}
 
Example 11
Source File: OffsetTime.java    From jdk8u-dev-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a copy of this time with the specified amount added.
 * <p>
 * This returns an {@code OffsetTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Duration} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return an {@code OffsetTime} based on this time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public OffsetTime plus(TemporalAmount amountToAdd) {
    return (OffsetTime) amountToAdd.addTo(this);
}
 
Example 12
Source File: OffsetDateTime.java    From j2objc with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a copy of this date-time with the specified amount added.
 * <p>
 * This returns an {@code OffsetDateTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} or {@link Duration} but may be
 * any other type implementing the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return an {@code OffsetDateTime} based on this date-time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public OffsetDateTime plus(TemporalAmount amountToAdd) {
    return (OffsetDateTime) amountToAdd.addTo(this);
}
 
Example 13
Source File: Instant.java    From jdk8u-jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a copy of this instant with the specified amount added.
 * <p>
 * This returns an {@code Instant}, based on this one, with the specified amount added.
 * The amount is typically {@link Duration} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return an {@code Instant} based on this instant with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Instant plus(TemporalAmount amountToAdd) {
    return (Instant) amountToAdd.addTo(this);
}
 
Example 14
Source File: LocalTime.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a copy of this time with the specified amount added.
 * <p>
 * This returns a {@code LocalTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Duration} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalTime} based on this time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalTime plus(TemporalAmount amountToAdd) {
    return (LocalTime) amountToAdd.addTo(this);
}
 
Example 15
Source File: Year.java    From Java8CN with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a copy of this year with the specified amount added.
 * <p>
 * This returns a {@code Year}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code Year} based on this year with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Year plus(TemporalAmount amountToAdd) {
    return (Year) amountToAdd.addTo(this);
}
 
Example 16
Source File: OffsetTime.java    From jdk8u_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a copy of this time with the specified amount added.
 * <p>
 * This returns an {@code OffsetTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Duration} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return an {@code OffsetTime} based on this time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public OffsetTime plus(TemporalAmount amountToAdd) {
    return (OffsetTime) amountToAdd.addTo(this);
}
 
Example 17
Source File: LocalTime.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a copy of this time with the specified amount added.
 * <p>
 * This returns a {@code LocalTime}, based on this one, with the specified amount added.
 * The amount is typically {@link Duration} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code LocalTime} based on this time with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalTime plus(TemporalAmount amountToAdd) {
    return (LocalTime) amountToAdd.addTo(this);
}
 
Example 18
Source File: Instant.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a copy of this instant with the specified amount added.
 * <p>
 * This returns an {@code Instant}, based on this one, with the specified amount added.
 * The amount is typically {@link Duration} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return an {@code Instant} based on this instant with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Instant plus(TemporalAmount amountToAdd) {
    return (Instant) amountToAdd.addTo(this);
}
 
Example 19
Source File: YearMonth.java    From dragonwell8_jdk with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Returns a copy of this year-month with the specified amount added.
 * <p>
 * This returns a {@code YearMonth}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code YearMonth} based on this year-month with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public YearMonth plus(TemporalAmount amountToAdd) {
    return (YearMonth) amountToAdd.addTo(this);
}
 
Example 20
Source File: Year.java    From jdk1.8-source-analysis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a copy of this year with the specified amount added.
 * <p>
 * This returns a {@code Year}, based on this one, with the specified amount added.
 * The amount is typically {@link Period} but may be any other type implementing
 * the {@link TemporalAmount} interface.
 * <p>
 * The calculation is delegated to the amount object by calling
 * {@link TemporalAmount#addTo(Temporal)}. The amount implementation is free
 * to implement the addition in any way it wishes, however it typically
 * calls back to {@link #plus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully added.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToAdd  the amount to add, not null
 * @return a {@code Year} based on this year with the addition made, not null
 * @throws DateTimeException if the addition cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Year plus(TemporalAmount amountToAdd) {
    return (Year) amountToAdd.addTo(this);
}