當前位置: 首頁>>代碼示例>>Java>>正文


Java Duration.minusDays方法代碼示例

本文整理匯總了Java中java.time.Duration.minusDays方法的典型用法代碼示例。如果您正苦於以下問題:Java Duration.minusDays方法的具體用法?Java Duration.minusDays怎麽用?Java Duration.minusDays使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.time.Duration的用法示例。


在下文中一共展示了Duration.minusDays方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
 
開發者ID:ViniciusArnhold,項目名稱:ProjectAltaria,代碼行數:20,代碼來源:TimeUtils.java

示例2: durationInMillisToString

import java.time.Duration; //導入方法依賴的package包/類
private static String durationInMillisToString(Duration duration) {
	long days = duration.toDays(); // chop off any days as formatter can't handle them
	duration = duration.minusDays(days);

	// convert duration to a time by adding it to midnight
	LocalTime durationAsTime = LocalTime.MIDNIGHT.plus(duration);
	String result = formatter.format(durationAsTime);

	if (days > 0) result = String.format("%dd ", days) + result;
	return result;
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:12,代碼來源:SolsticeScanMonitor.java

示例3: minusDays_long

import java.time.Duration; //導入方法依賴的package包/類
@Test(dataProvider="MinusDays")
public void minusDays_long(long days, long amount, long expectedDays) {
    Duration t = Duration.ofDays(days);
    t = t.minusDays(amount);
    assertEquals(t.toDays(), expectedDays);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:7,代碼來源:TCKDuration.java

示例4: minusDays_long_overflowTooBig

import java.time.Duration; //導入方法依賴的package包/類
@Test(expectedExceptions = {ArithmeticException.class})
public void minusDays_long_overflowTooBig() {
    Duration t = Duration.ofDays(Long.MAX_VALUE/3600/24);
    t.minusDays(-1);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKDuration.java

示例5: minusDays_long_overflowTooSmall

import java.time.Duration; //導入方法依賴的package包/類
@Test(expectedExceptions = {ArithmeticException.class})
public void minusDays_long_overflowTooSmall() {
    Duration t = Duration.ofDays(Long.MIN_VALUE/3600/24);
    t.minusDays(1);
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:6,代碼來源:TCKDuration.java


注:本文中的java.time.Duration.minusDays方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。