本文整理汇总了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;
}
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
示例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));
}
示例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);
}