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


Java Duration.minus方法代码示例

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


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

示例1: subtractCaptureTime

import java.time.Duration; //导入方法依赖的package包/类
private @Nullable Duration subtractCaptureTime(final Duration duration) {
    if(Comparables.greaterThan(progress, duration)) {
        progress = progress.minus(duration);
        return null;
    } else {
        final Duration remainder = duration.minus(progress);
        progress = Duration.ZERO;
        return remainder;
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:11,代码来源:ControlPoint.java

示例2: inUnits

import java.time.Duration; //导入方法依赖的package包/类
public static TimePeriod inUnits(Duration duration, Collection<TemporalUnit> units) {
    final ImmutableMap.Builder<TemporalUnit, Long> builder = ImmutableMap.builder();
    for(TemporalUnit unit : IterableUtils.sorted(units, TimeUtils.descendingUnits())) {
        if(!TimeUtils.isPrecise(unit)) {
            throw new IllegalArgumentException("Imprecise unit " + unit);
        }

        if(Comparables.greaterOrEqual(duration, unit.getDuration())) {
            final long amount = TimeUtils.toUnit(unit, duration);
            builder.put(unit, amount);
            duration = duration.minus(amount, unit);
        }
    }
    return new TimePeriod(builder.build());
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:16,代码来源:TimePeriod.java

示例3: minus_longTemporalUnit_seconds

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void minus_longTemporalUnit_seconds() {
    Duration t = Duration.ofSeconds(1);
    t = t.minus(1, SECONDS);
    assertEquals(0, t.getSeconds());
    assertEquals(0, t.getNano());
 }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDuration.java

示例4: minus_longTemporalUnit_millis

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void minus_longTemporalUnit_millis() {
    Duration t = Duration.ofSeconds(1);
    t = t.minus(1, MILLIS);
    assertEquals(0, t.getSeconds());
    assertEquals(999000000, t.getNano());
 }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDuration.java

示例5: minus_longTemporalUnit_micros

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void minus_longTemporalUnit_micros() {
    Duration t = Duration.ofSeconds(1);
    t = t.minus(1, MICROS);
    assertEquals(0, t.getSeconds());
    assertEquals(999999000, t.getNano());
 }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDuration.java

示例6: minus_longTemporalUnit_nanos

import java.time.Duration; //导入方法依赖的package包/类
@Test
public void minus_longTemporalUnit_nanos() {
    Duration t = Duration.ofSeconds(1);
    t = t.minus(1, NANOS);
    assertEquals(0, t.getSeconds());
    assertEquals(999999999, t.getNano());
 }
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKDuration.java

示例7: minusOverflowTooSmall

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=ArithmeticException.class)
public void minusOverflowTooSmall() {
   Duration t = Duration.ofSeconds(Long.MIN_VALUE);
   t.minus(Duration.ofSeconds(0, 1));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKDuration.java

示例8: minusOverflowTooBig

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=ArithmeticException.class)
public void minusOverflowTooBig() {
   Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999);
   t.minus(Duration.ofSeconds(-1, 999999999));
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKDuration.java

示例9: minus_longTemporalUnit_null

import java.time.Duration; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void minus_longTemporalUnit_null() {
   Duration t = Duration.ofSeconds(1);
   t.minus(1, (TemporalUnit) null);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKDuration.java


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