本文整理匯總了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);
}