本文整理匯總了Java中java.time.Duration.minusMinutes方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.minusMinutes方法的具體用法?Java Duration.minusMinutes怎麽用?Java Duration.minusMinutes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.time.Duration
的用法示例。
在下文中一共展示了Duration.minusMinutes方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: formatAsElapsed
import java.time.Duration; //導入方法依賴的package包/類
public static String formatAsElapsed() {
Duration elapsed = Duration.ofMillis(ManagementFactory.getRuntimeMXBean().getUptime());
long days = elapsed.toDays();
elapsed = elapsed.minusDays(days);
long hours = elapsed.toHours();
elapsed = elapsed.minusHours(hours);
long minutes = elapsed.toMinutes();
elapsed = elapsed.minusMinutes(minutes);
long seconds = elapsed.getSeconds();
elapsed = elapsed.minusSeconds(seconds);
long millis = elapsed.toMillis();
return String.format(TIME_FORMAT,
days,
hours,
minutes,
seconds,
millis);
}
示例2: minusMinutes_long
import java.time.Duration; //導入方法依賴的package包/類
@Test(dataProvider="MinusMinutes")
public void minusMinutes_long(long minutes, long amount, long expectedMinutes) {
Duration t = Duration.ofMinutes(minutes);
t = t.minusMinutes(amount);
assertEquals(t.toMinutes(), expectedMinutes);
}
示例3: minusMinutes_long_overflowTooBig
import java.time.Duration; //導入方法依賴的package包/類
@Test(expectedExceptions = {ArithmeticException.class})
public void minusMinutes_long_overflowTooBig() {
Duration t = Duration.ofMinutes(Long.MAX_VALUE/60);
t.minusMinutes(-1);
}
示例4: minusMinutes_long_overflowTooSmall
import java.time.Duration; //導入方法依賴的package包/類
@Test(expectedExceptions = {ArithmeticException.class})
public void minusMinutes_long_overflowTooSmall() {
Duration t = Duration.ofMinutes(Long.MIN_VALUE/60);
t.minusMinutes(1);
}