當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。