Java Code Examples for java.time.Duration#multipliedBy()
The following examples show how to use
java.time.Duration#multipliedBy() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: smallrye-mutiny File: ExponentialBackoff.java License: Apache License 2.0 | 5 votes |
private static Duration getNextAttemptDelay(Duration firstBackoff, Duration maxBackoff, int iteration) { Duration nextBackoff; try { nextBackoff = firstBackoff.multipliedBy((long) Math.pow(2, iteration)); if (nextBackoff.compareTo(maxBackoff) > 0) { nextBackoff = maxBackoff; } } catch (ArithmeticException overflow) { nextBackoff = maxBackoff; } return nextBackoff; }
Example 2
Source Project: TencentKona-8 File: TCKDuration.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="MultipliedBy") public void multipliedBy(long seconds, int nanos, int multiplicand, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.multipliedBy(multiplicand); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanos); }
Example 3
Source Project: jdk8u60 File: TCKDuration.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="MultipliedBy") public void multipliedBy(long seconds, int nanos, int multiplicand, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.multipliedBy(multiplicand); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanos); }
Example 4
Source Project: Discord4J File: VoiceGatewayRetrySpec.java License: GNU Lesser General Public License v3.0 | 5 votes |
static Duration computeBackoff(long iteration, Duration minBackoff, Duration maxBackoff) { Duration nextBackoff; try { nextBackoff = minBackoff.multipliedBy((long) Math.pow(2, iteration)); if (nextBackoff.compareTo(maxBackoff) > 0) { nextBackoff = maxBackoff; } } catch (ArithmeticException overflow) { nextBackoff = maxBackoff; } return nextBackoff; }
Example 5
Source Project: ditto File: BackOffActor.java License: Eclipse Public License 2.0 | 5 votes |
private void backOff(final BackOffWithAnswer<?> backOffWithAnswer) { final Duration backOffTimeout = this.retryTimeoutStrategy.getNextTimeout(); final Duration resetBackOffTimeout = backOffTimeout.multipliedBy(2L); log.debug("Going to back off for <{}> until sending answer: <{}>", backOffTimeout, backOffWithAnswer.getAnswer()); this.getTimers().startSingleTimer(InternalTimers.BACK_OFF, new BackOffWithSender<>(getSender(), backOffWithAnswer), backOffTimeout); this.getTimers().startSingleTimer(InternalTimers.RESET_BACK_OFF, RESET_BACK_OFF, resetBackOffTimeout); }
Example 6
Source Project: jdk8u-dev-jdk File: TCKDuration.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="MultipliedBy") public void multipliedBy(long seconds, int nanos, int multiplicand, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.multipliedBy(multiplicand); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanos); }
Example 7
Source Project: vespa File: DelaySupplier.java License: Apache License 2.0 | 5 votes |
@Override public Duration getDelay(int executionCount) { Duration nextDelay = startDelay; for (int i = 1; i < executionCount; ++i) { nextDelay = nextDelay.multipliedBy(2); } return maxDelay.compareTo(nextDelay) > 0 ? nextDelay : maxDelay; }
Example 8
Source Project: j2objc File: TCKDuration.java License: Apache License 2.0 | 5 votes |
@Test() @UseDataProvider("provider_multipliedBy") public void multipliedBy(long seconds, int nanos, int multiplicand, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.multipliedBy(multiplicand); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanos); }
Example 9
Source Project: openjdk-jdk9 File: TCKDuration.java License: GNU General Public License v2.0 | 5 votes |
@Test(dataProvider="MultipliedBy") public void multipliedBy(long seconds, int nanos, int multiplicand, long expectedSeconds, int expectedNanos) { Duration t = Duration.ofSeconds(seconds, nanos); t = t.multipliedBy(multiplicand); assertEquals(t.getSeconds(), expectedSeconds); assertEquals(t.getNano(), expectedNanos); }
Example 10
Source Project: jdk8u_jdk File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MAX_VALUE); }
Example 11
Source Project: jdk8u-jdk File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig_negative() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MIN_VALUE); }
Example 12
Source Project: dragonwell8_jdk File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig_negative() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MIN_VALUE); }
Example 13
Source Project: TencentKona-8 File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MAX_VALUE); }
Example 14
Source Project: TencentKona-8 File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig_negative() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MIN_VALUE); }
Example 15
Source Project: openjdk-8-source File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig_negative() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MIN_VALUE); }
Example 16
Source Project: teku File: Waiter.java License: Apache License 2.0 | 4 votes |
private static Duration nextPollInterval(final Duration duration) { final Duration nextInterval = duration.multipliedBy(2); return nextInterval.compareTo(MAX_POLL_INTERVAL) <= 0 ? nextInterval : MAX_POLL_INTERVAL; }
Example 17
Source Project: hottub File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MAX_VALUE); }
Example 18
Source Project: openjdk-8-source File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MAX_VALUE); }
Example 19
Source Project: openjdk-jdk9 File: TCKDuration.java License: GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ArithmeticException.class) public void multipliedBy_tooBig() { Duration test = Duration.ofSeconds(1, 1); test.multipliedBy(Long.MAX_VALUE); }
Example 20
Source Project: groovy File: DateTimeExtensions.java License: Apache License 2.0 | 2 votes |
/** * Supports the multiplication operator; equivalent to calling the {@link Duration#multipliedBy(long)} method. * * @param self a Duration * @param scalar the value to multiply by * @return a Duration * @since 2.5.0 */ public static Duration multiply(final Duration self, long scalar) { return self.multipliedBy(scalar); }