当前位置: 首页>>代码示例>>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;未经允许,请勿转载。