本文整理了Java中java.time.Duration.minusMillis()
方法的一些代码示例,展示了Duration.minusMillis()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.minusMillis()
方法的具体详情如下:
包路径:java.time.Duration
类名称:Duration
方法名:minusMillis
[英]Returns a copy of this duration with the specified duration in milliseconds subtracted.
This instance is immutable and unaffected by this method call.
[中]返回此持续时间的副本,并减去指定的持续时间(毫秒)。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: runelite/runelite
String getTime(boolean waveTime)
{
final Instant now = Instant.now();
final Duration elapsed;
if (waveTime)
{
elapsed = Duration.between(prevWave, now);
}
else
{
elapsed = Duration.between(startTime, now).minusMillis(600);
}
return formatTime(LocalTime.ofSecondOfDay(elapsed.getSeconds()));
}
代码示例来源:origin: Azure/azure-service-bus-java
public static Duration adjustServerTimeout(Duration clientTimeout)
{
return clientTimeout.minusMillis(100);
}
代码示例来源:origin: com.swrve/rate-limited-logger
@GuardedBy("this")
private void reportSuppression(long whenLimited) {
long count = counter.get();
counter.addAndGet(-count);
long numSuppressed = count - rateAndPeriod.maxRate;
if (numSuppressed == 0) {
return; // special case: we hit the rate limit, but did not actually exceed it -- nothing got suppressed, so there's no need to log
}
Duration howLong = Duration.ofMillis(elapsedMsecs()).minusMillis(whenLimited);
level.log(logger, "(suppressed {} logs similar to '{}' in {})", numSuppressed, message, howLong);
}
代码示例来源:origin: com.bazaarvoice.emodb/emodb-common-api
public static Integer toSeconds(Duration ttl, int minimum, Integer forever) {
if (ttl == null) {
return forever;
}
checkArgument(ttl.compareTo(Duration.ZERO) >= 0, "Ttl may not be negative: {}", ttl);
// Convert to seconds, rounding up.
long seconds = ttl.plusSeconds(1).minusMillis(1).getSeconds();
// No support for really large numbers, convert to forever.
if (seconds > Integer.MAX_VALUE) {
return forever;
}
// Constrain to min/max
if (seconds < minimum) {
return minimum;
}
if (forever != null && seconds > forever) {
return forever;
}
return (int) seconds;
}
}
代码示例来源:origin: bazaarvoice/emodb
public static Integer toSeconds(Duration ttl, int minimum, Integer forever) {
if (ttl == null) {
return forever;
}
checkArgument(ttl.compareTo(Duration.ZERO) >= 0, "Ttl may not be negative: {}", ttl);
// Convert to seconds, rounding up.
long seconds = ttl.plusSeconds(1).minusMillis(1).getSeconds();
// No support for really large numbers, convert to forever.
if (seconds > Integer.MAX_VALUE) {
return forever;
}
// Constrain to min/max
if (seconds < minimum) {
return minimum;
}
if (forever != null && seconds > forever) {
return forever;
}
return (int) seconds;
}
}
代码示例来源:origin: com.github.crisposs/jabs-api
public static Duration subtractFromDuration(Duration d, long v) {
if (isDurationInfinite(d)) {
return d;
}
Duration d2 = d.minusMillis(v);
return d2.isNegative() || d2.isZero() ? d : d2;
}
代码示例来源:origin: rickfast/consul-client
if (!Duration.between(blacklistWhen, Instant.now()).minusMillis(timeout).isNegative()) {
blacklist.remove(target);
return true;
代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-test
remainingDuration = remainingDuration.minusMillis(end - start);
内容来源于网络,如有侵权,请联系作者删除!