當前位置: 首頁>>代碼示例>>Java>>正文


Java TemporalAmount.addTo方法代碼示例

本文整理匯總了Java中java.time.temporal.TemporalAmount.addTo方法的典型用法代碼示例。如果您正苦於以下問題:Java TemporalAmount.addTo方法的具體用法?Java TemporalAmount.addTo怎麽用?Java TemporalAmount.addTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.temporal.TemporalAmount的用法示例。


在下文中一共展示了TemporalAmount.addTo方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:LocalDate.java

示例2: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:LocalDateTime.java

示例3: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:30,代碼來源:ZonedDateTime.java

示例4: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:25,代碼來源:Instant.java

示例5: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:YearMonth.java

示例6: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:OffsetDateTime.java

示例7: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:LocalTime.java

示例8: plus

import java.time.temporal.TemporalAmount; //導入方法依賴的package包/類
/**
 * 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);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:25,代碼來源:Year.java


注:本文中的java.time.temporal.TemporalAmount.addTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。