本文整理了Java中org.apache.brooklyn.util.time.Time.elapsedSince()
方法的一些代码示例,展示了Time.elapsedSince()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Time.elapsedSince()
方法的具体详情如下:
包路径:org.apache.brooklyn.util.time.Time
类名称:Time
方法名:elapsedSince
[英]returns the duration elapsed since the given timestamp (UTC)
[中]返回自给定时间戳(UTC)以来经过的持续时间
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
/** true iff it has been longer than the given duration since the given timestamp */
public static boolean hasElapsedSince(long timestamp, Duration duration) {
return elapsedSince(timestamp).compareTo(duration) > 0;
}
代码示例来源:origin: org.apache.brooklyn/brooklyn-utils-common
@Test
public void testElapsedSince() {
long aFewSecondsAgo = System.currentTimeMillis() - 7*1000;
Duration aFewSeconds = Time.elapsedSince(aFewSecondsAgo);
Assert.assertTrue(aFewSeconds.toMilliseconds() > 5*1000);
Assert.assertTrue(10*1000 > aFewSeconds.toMilliseconds());
Assert.assertTrue(Time.hasElapsedSince(aFewSecondsAgo, Duration.FIVE_SECONDS));
Assert.assertFalse(Time.hasElapsedSince(aFewSecondsAgo, Duration.TEN_SECONDS));
Assert.assertTrue(Time.hasElapsedSince(-1, Duration.TEN_SECONDS));
}
内容来源于网络,如有侵权,请联系作者删除!