本文整理了Java中java.time.Duration.dividedBy()
方法的一些代码示例,展示了Duration.dividedBy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Duration.dividedBy()
方法的具体详情如下:
包路径:java.time.Duration
类名称:Duration
方法名:dividedBy
[英]Returns a copy of this duration divided by the specified value.
This instance is immutable and unaffected by this method call.
[中]返回此持续时间除以指定值的副本。
此实例是不可变的,不受此方法调用的影响。
代码示例来源:origin: thinkaurelius/titan
private static final Duration pertubateTime(Duration duration) {
Duration newDuration = duration.dividedBy((int)(2.0 / (1 + (random.nextDouble() * 2 - 1.0) * PERTURBATION_PERCENTAGE)));
assert !duration.isZero() : duration;
return newDuration;
}
代码示例来源:origin: JanusGraph/janusgraph
private static Duration pertubTime(Duration duration) {
Duration newDuration = duration.dividedBy((int)(2.0 / (1 + (random.nextDouble() * 2 - 1.0) * PERTURBATION_PERCENTAGE)));
assert !duration.isZero() : duration;
return newDuration;
}
代码示例来源:origin: oracle/helidon
/**
* Builds a new recurring policy.
*
* @return the new instance
*/
public RecurringPolicy build() {
Duration min = this.min == null ? interval.dividedBy(10) : this.min;
Duration max = this.max == null ? interval.multipliedBy(5) : this.max;
BiFunction<Duration, Integer, Duration> lengthenFunction = this.lengthenFunction == null
? DEFAULT_LENGTHEN : this.lengthenFunction;
BiFunction<Duration, Integer, Duration> shortenFunction = this.shortenFunction == null
? DEFAULT_SHORTEN : this.shortenFunction;
return new ScheduledPollingStrategy.AdaptiveRecurringPolicy(min, interval, max, shortenFunction,
lengthenFunction);
}
代码示例来源:origin: reactor/reactor-core
try {
jitterOffset = nextBackoff.multipliedBy((long) (100 * jitterFactor))
.dividedBy(100)
.toMillis();
代码示例来源:origin: thinkaurelius/titan
this.idStore = idStore;
this.times = config.get(TIMESTAMP_PROVIDER);
this.waitGracePeriod = idApplicationWaitMS.dividedBy(10);
Preconditions.checkNotNull(times);
代码示例来源:origin: JanusGraph/janusgraph
this.idStore = idStore;
this.times = config.get(TIMESTAMP_PROVIDER);
this.waitGracePeriod = idApplicationWaitMS.dividedBy(10);
Preconditions.checkNotNull(times);
代码示例来源:origin: org.codehaus.groovy/groovy-datetime
/**
* Supports the division operator; equivalent to calling the {@link Duration#dividedBy(long)} method.
*
* @param self a Duration
* @param scalar the value to divide by
* @return a Duration
* @since 2.5.0
*/
public static Duration div(final Duration self, long scalar) {
return self.dividedBy(scalar);
}
代码示例来源:origin: com.thinkaurelius.titan/titan-core
private static final Duration pertubateTime(Duration duration) {
Duration newDuration = duration.dividedBy((int)(2.0 / (1 + (random.nextDouble() * 2 - 1.0) * PERTURBATION_PERCENTAGE)));
assert !duration.isZero() : duration;
return newDuration;
}
代码示例来源:origin: advantageous/reakt
public ReactorImpl(final Duration defaultTimeout,
final TimeSource timeSource) {
this.defaultTimeout = defaultTimeout;
final Duration checkPromiseTimeoutInterval = defaultTimeout.dividedBy(10);
this.timeSource = timeSource;
this.addRepeatingTask(checkPromiseTimeoutInterval, this::processPromiseTimeouts);
}
代码示例来源:origin: io.advantageous.reakt/reakt
public ReactorImpl(final Duration defaultTimeout,
final TimeSource timeSource) {
this.defaultTimeout = defaultTimeout;
final Duration checkPromiseTimeoutInterval = defaultTimeout.dividedBy(10);
this.timeSource = timeSource;
this.addRepeatingTask(checkPromiseTimeoutInterval, this::processPromiseTimeouts);
}
代码示例来源:origin: Azure/azure-service-bus-java
protected static Duration getNextRenewInterval(Instant lockedUntilUtc, String identifier) {
Duration remainingTime = Duration.between(Instant.now(), lockedUntilUtc);
if (remainingTime.isNegative()) {
// Lock likely expired. May be there is clock skew. Assume some minimum time
remainingTime = MessageAndSessionPump.MINIMUM_MESSAGE_LOCK_VALIDITY;
TRACE_LOGGER.warn("Lock of '{}' already expired. May be there is clock skew. Still trying to renew lock", identifier);
}
Duration buffer = remainingTime.dividedBy(2).compareTo(MAXIMUM_RENEW_LOCK_BUFFER) > 0 ? MAXIMUM_RENEW_LOCK_BUFFER : remainingTime.dividedBy(2);
TRACE_LOGGER.debug("Lock of '{}' is valid for '{}'. It will be renewed '{}' before it expires.", identifier, remainingTime, buffer);
return remainingTime.minus(buffer);
}
}
代码示例来源:origin: com.cedarsoft.commons/javafx
/**
* Returns the time at the center
*/
@Nonnull
public LocalDateTime getCenter() {
Duration duration = getDuration();
return start.plus(duration.dividedBy(2));
}
代码示例来源:origin: com.cedarsoft.commons/javafx
/**
* Creates a new date range with the same duration but the center at the given position
*/
@Nonnull
public DateTimeRange withCenterAt(@Nonnull LocalDateTime center) {
Duration duration = getDuration();
LocalDateTime start = center.minus(duration.dividedBy(2));
LocalDateTime plus = center.plus(duration.dividedBy(2));
return new DateTimeRange(start, plus);
}
代码示例来源:origin: com.yahoo.vespa/vespa-athenz
private static <KEY, VALUE> LoadingCache<KEY, VALUE> createCache(Duration expiry, Function<KEY, VALUE> cacheLoader) {
return CacheBuilder.newBuilder()
.refreshAfterWrite(expiry.dividedBy(2).toMinutes(), TimeUnit.MINUTES)
.expireAfterWrite(expiry.toMinutes(), TimeUnit.MINUTES)
.build(new CacheLoader<KEY, VALUE>() {
@Override
public VALUE load(KEY key) {
return cacheLoader.apply(key);
}
});
}
代码示例来源:origin: me.tongfei/progressbar
String eta(Duration elapsed) {
if (progress.max <= 0 || progress.indefinite) return "?";
else if (progress.current == 0) return "?";
else return Util.formatDuration(
elapsed.dividedBy(progress.current)
.multipliedBy(progress.max - progress.current)
);
}
代码示例来源:origin: ctongfei/progressbar
String eta(Duration elapsed) {
if (progress.max <= 0 || progress.indefinite) return "?";
else if (progress.current == 0) return "?";
else return Util.formatDuration(
elapsed.dividedBy(progress.current)
.multipliedBy(progress.max - progress.current)
);
}
代码示例来源:origin: goldmansachs/jdmn
private TemporalAmount divide(TemporalAmount first, int second) {
if (first instanceof Period) {
long months = ((Period)first).toTotalMonths() / second;
return Period.ofMonths((int)months);
} else if (first instanceof Duration) {
return ((Duration)first).dividedBy(second);
} else {
throw new DMNRuntimeException(String.format("Cannot divide '%s' by '%s'", first, second));
}
}
}
代码示例来源:origin: com.goldmansachs.jdmn/jdmn-core
private TemporalAmount divide(TemporalAmount first, int second) {
if (first instanceof Period) {
long months = ((Period)first).toTotalMonths() / second;
return Period.ofMonths((int)months);
} else if (first instanceof Duration) {
return ((Duration)first).dividedBy(second);
} else {
throw new DMNRuntimeException(String.format("Cannot divide '%s' by '%s'", first, second));
}
}
}
代码示例来源:origin: RS485/LogisticsPipes
private void increaseGroupIndex() {
currentGroupIndex++;
if (currentGroupIndex >= meanCalcCallCount) {
currentGroupIndex = 0;
if (printToConsole) {
Duration sum = getSum();
Duration mean = sum.dividedBy(meanCalcCallCount);
System.out.printf("Sum: %s of %d measures - Mean time: %s%n",
sum.toString(), meanCalcCallCount, mean.toString());
}
}
}
代码示例来源:origin: org.neo4j/neo4j-causal-clustering
private LeaderAvailabilityTimers createElectionTiming( Config config, TimerService timerService, LogProvider logProvider )
{
Duration electionTimeout = config.get( CausalClusteringSettings.leader_election_timeout );
return new LeaderAvailabilityTimers( electionTimeout, electionTimeout.dividedBy( 3 ), systemClock(), timerService, logProvider );
}
内容来源于网络,如有侵权,请联系作者删除!