当前位置: 首页>>代码示例>>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;未经允许,请勿转载。