当前位置: 首页>>代码示例>>Java>>正文


Java TemporalAmount.subtractFrom方法代码示例

本文整理汇总了Java中java.time.temporal.TemporalAmount.subtractFrom方法的典型用法代码示例。如果您正苦于以下问题:Java TemporalAmount.subtractFrom方法的具体用法?Java TemporalAmount.subtractFrom怎么用?Java TemporalAmount.subtractFrom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.time.temporal.TemporalAmount的用法示例。


在下文中一共展示了TemporalAmount.subtractFrom方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this date-time with the specified amount subtracted.
 * <p>
 * This returns a {@code LocalDateTime}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return a {@code LocalDateTime} based on this date-time with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDateTime minus(TemporalAmount amountToSubtract) {
    if (amountToSubtract instanceof Period) {
        Period periodToSubtract = (Period) amountToSubtract;
        return with(date.minus(periodToSubtract), time);
    }
    Objects.requireNonNull(amountToSubtract, "amountToSubtract");
    return (LocalDateTime) amountToSubtract.subtractFrom(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:30,代码来源:LocalDateTime.java

示例2: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this date-time with the specified amount subtracted.
 * <p>
 * This returns a {@code ZonedDateTime}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return a {@code ZonedDateTime} based on this date-time with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public ZonedDateTime minus(TemporalAmount amountToSubtract) {
    if (amountToSubtract instanceof Period) {
        Period periodToSubtract = (Period) amountToSubtract;
        return resolveLocal(dateTime.minus(periodToSubtract));
    }
    Objects.requireNonNull(amountToSubtract, "amountToSubtract");
    return (ZonedDateTime) amountToSubtract.subtractFrom(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:30,代码来源:ZonedDateTime.java

示例3: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this date with the specified amount subtracted.
 * <p>
 * This returns a {@code LocalDate}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return a {@code LocalDate} based on this date with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalDate minus(TemporalAmount amountToSubtract) {
    if (amountToSubtract instanceof Period) {
        Period periodToSubtract = (Period) amountToSubtract;
        return minusMonths(periodToSubtract.toTotalMonths()).minusDays(periodToSubtract.getDays());
    }
    Objects.requireNonNull(amountToSubtract, "amountToSubtract");
    return (LocalDate) amountToSubtract.subtractFrom(this);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:30,代码来源:LocalDate.java

示例4: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this time with the specified amount subtracted.
 * <p>
 * This returns an {@code OffsetTime}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return an {@code OffsetTime} based on this time with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public OffsetTime minus(TemporalAmount amountToSubtract) {
    return (OffsetTime) amountToSubtract.subtractFrom(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:OffsetTime.java

示例5: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this date-time with the specified amount subtracted.
 * <p>
 * This returns an {@code OffsetDateTime}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return an {@code OffsetDateTime} based on this date-time with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public OffsetDateTime minus(TemporalAmount amountToSubtract) {
    return (OffsetDateTime) amountToSubtract.subtractFrom(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:OffsetDateTime.java

示例6: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this instant with the specified amount subtracted.
 * <p>
 * This returns an {@code Instant}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return an {@code Instant} based on this instant with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Instant minus(TemporalAmount amountToSubtract) {
    return (Instant) amountToSubtract.subtractFrom(this);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:Instant.java

示例7: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this year with the specified amount subtracted.
 * <p>
 * This returns a {@code Year}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return a {@code Year} based on this year with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public Year minus(TemporalAmount amountToSubtract) {
    return (Year) amountToSubtract.subtractFrom(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:Year.java

示例8: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this time with the specified amount subtracted.
 * <p>
 * This returns a {@code LocalTime}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return a {@code LocalTime} based on this time with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public LocalTime minus(TemporalAmount amountToSubtract) {
    return (LocalTime) amountToSubtract.subtractFrom(this);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:25,代码来源:LocalTime.java

示例9: minus

import java.time.temporal.TemporalAmount; //导入方法依赖的package包/类
/**
 * Returns a copy of this year-month with the specified amount subtracted.
 * <p>
 * This returns a {@code YearMonth}, based on this one, with the specified amount subtracted.
 * 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#subtractFrom(Temporal)}. The amount implementation is free
 * to implement the subtraction in any way it wishes, however it typically
 * calls back to {@link #minus(long, TemporalUnit)}. Consult the documentation
 * of the amount implementation to determine if it can be successfully subtracted.
 * <p>
 * This instance is immutable and unaffected by this method call.
 *
 * @param amountToSubtract  the amount to subtract, not null
 * @return a {@code YearMonth} based on this year-month with the subtraction made, not null
 * @throws DateTimeException if the subtraction cannot be made
 * @throws ArithmeticException if numeric overflow occurs
 */
@Override
public YearMonth minus(TemporalAmount amountToSubtract) {
    return (YearMonth) amountToSubtract.subtractFrom(this);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:YearMonth.java


注:本文中的java.time.temporal.TemporalAmount.subtractFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。