Java Code Examples for java.time.Duration#ofSeconds()
The following examples show how to use
java.time.Duration#ofSeconds() .
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 File: DelayedConnectionLevelRetryHandlerTest.java From vespa with Apache License 2.0 | 6 votes |
@Test public void retry_with_fixed_delay_sleeps_for_expected_duration() { Sleeper sleeper = mock(Sleeper.class); Duration delay = Duration.ofSeconds(2); int maxRetries = 2; DelayedConnectionLevelRetryHandler handler = DelayedConnectionLevelRetryHandler.Builder .withFixedDelay(delay, maxRetries) .withSleeper(sleeper) .build(); IOException exception = new IOException(); HttpClientContext ctx = new HttpClientContext(); int lastExecutionCount = maxRetries + 1; for (int i = 1; i <= lastExecutionCount; i++) { handler.retryRequest(exception, i, ctx); } verify(sleeper, times(2)).sleep(delay); }
Example 2
Source File: RntbdTransportClient.java From azure-cosmosdb-java with MIT License | 6 votes |
private Options() { this.bufferPageSize = 8192; this.connectionTimeout = null; this.idleChannelTimeout = Duration.ZERO; this.idleEndpointTimeout = Duration.ofSeconds(70L); this.maxBufferCapacity = 8192 << 10; this.maxChannelsPerEndpoint = 10; this.maxRequestsPerChannel = 30; this.receiveHangDetectionTime = Duration.ofSeconds(65L); this.requestExpiryInterval = Duration.ofSeconds(5L); this.requestTimeout = null; this.requestTimerResolution = Duration.ofMillis(5L); this.sendHangDetectionTime = Duration.ofSeconds(10L); this.shutdownTimeout = Duration.ofSeconds(15L); this.userAgent = new UserAgentContainer(); }
Example 3
Source File: TCKDuration.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Test public void plus_longTemporalUnit_nanos() { Duration t = Duration.ofSeconds(1); t = t.plus(1, NANOS); assertEquals(1, t.getSeconds()); assertEquals(1, t.getNano()); }
Example 4
Source File: TCKYearMonth.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
@DataProvider(name="plus_TemporalAmount") Object[][] data_plus_TemporalAmount() { return new Object[][] { {YearMonth.of(1, 1), Period.ofYears(1), YearMonth.of(2, 1), null}, {YearMonth.of(1, 1), Period.ofYears(-12), YearMonth.of(-11, 1), null}, {YearMonth.of(1, 1), Period.ofYears(0), YearMonth.of(1, 1), null}, {YearMonth.of(999999999, 12), Period.ofYears(0), YearMonth.of(999999999, 12), null}, {YearMonth.of(-999999999, 1), Period.ofYears(0), YearMonth.of(-999999999, 1), null}, {YearMonth.of(0, 1), Period.ofYears(-999999999), YearMonth.of(-999999999, 1), null}, {YearMonth.of(0, 12), Period.ofYears(999999999), YearMonth.of(999999999, 12), null}, {YearMonth.of(1, 1), Period.ofMonths(1), YearMonth.of(1, 2), null}, {YearMonth.of(1, 1), Period.ofMonths(-12), YearMonth.of(0, 1), null}, {YearMonth.of(1, 1), Period.ofMonths(121), YearMonth.of(11, 2), null}, {YearMonth.of(1, 1), Period.ofMonths(0), YearMonth.of(1, 1), null}, {YearMonth.of(999999999, 12), Period.ofMonths(0), YearMonth.of(999999999, 12), null}, {YearMonth.of(-999999999, 1), Period.ofMonths(0), YearMonth.of(-999999999, 1), null}, {YearMonth.of(-999999999, 2), Period.ofMonths(-1), YearMonth.of(-999999999, 1), null}, {YearMonth.of(999999999, 11), Period.ofMonths(1), YearMonth.of(999999999, 12), null}, {YearMonth.of(1, 1), Period.ofYears(1).withMonths(2), YearMonth.of(2, 3), null}, {YearMonth.of(1, 1), Period.ofYears(-12).withMonths(-1), YearMonth.of(-12, 12), null}, {YearMonth.of(1, 1), Period.ofMonths(2).withYears(1), YearMonth.of(2, 3), null}, {YearMonth.of(1, 1), Period.ofMonths(-1).withYears(-12), YearMonth.of(-12, 12), null}, {YearMonth.of(1, 1), Period.ofDays(365), null, DateTimeException.class}, {YearMonth.of(1, 1), Duration.ofDays(365), null, DateTimeException.class}, {YearMonth.of(1, 1), Duration.ofHours(365*24), null, DateTimeException.class}, {YearMonth.of(1, 1), Duration.ofMinutes(365*24*60), null, DateTimeException.class}, {YearMonth.of(1, 1), Duration.ofSeconds(365*24*3600), null, DateTimeException.class}, {YearMonth.of(1, 1), Duration.ofNanos(365*24*3600*1000000000), null, DateTimeException.class}, }; }
Example 5
Source File: TCKDuration.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
@Test public void test_hashCode() { Duration test5a = Duration.ofSeconds(5L, 20); Duration test5b = Duration.ofSeconds(5L, 20); Duration test5n = Duration.ofSeconds(5L, 30); Duration test6 = Duration.ofSeconds(6L, 20); assertEquals(test5a.hashCode() == test5a.hashCode(), true); assertEquals(test5a.hashCode() == test5b.hashCode(), true); assertEquals(test5b.hashCode() == test5b.hashCode(), true); assertEquals(test5a.hashCode() == test5n.hashCode(), false); assertEquals(test5a.hashCode() == test6.hashCode(), false); }
Example 6
Source File: TCKDuration.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
@Test public void plusMillis_long_min() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000); t = t.plusMillis(-1); assertEquals(t.getSeconds(), Long.MIN_VALUE); assertEquals(t.getNano(), 0); }
Example 7
Source File: TCKDuration.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Test public void minus_longTemporalUnit_millis() { Duration t = Duration.ofSeconds(1); t = t.minus(1, MILLIS); assertEquals(0, t.getSeconds()); assertEquals(999000000, t.getNano()); }
Example 8
Source File: QueryIntegrationTestSupport.java From r2dbc-mysql with Apache License 2.0 | 5 votes |
@Test void time() { LocalTime minTime = LocalTime.MIDNIGHT; LocalTime aTime = LocalTime.of(10, 5, 28); LocalTime maxTime = LocalTime.of(23, 59, 59); Duration minDuration = Duration.ofSeconds(-TimeUnit.HOURS.toSeconds(838) - TimeUnit.MINUTES.toSeconds(59) - 59); Duration aDuration = Duration.ofSeconds(1854672); Duration maxDuration = Duration.ofSeconds(TimeUnit.HOURS.toSeconds(838) + TimeUnit.MINUTES.toSeconds(59) + 59); testType(LocalTime.class, true, "TIME", null, minTime, aTime, maxTime); testType(Duration.class, true, "TIME", null, minDuration, aDuration, maxDuration); }
Example 9
Source File: TCKDuration.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Test public void minusMillis_long_min() { Duration t = Duration.ofSeconds(Long.MIN_VALUE, 1000000); t = t.minusMillis(1); assertEquals(t.getSeconds(), Long.MIN_VALUE); assertEquals(t.getNano(), 0); }
Example 10
Source File: TestDuration.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Test public void minusMillis_zeroReturnsThis() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusMillis(0), t); }
Example 11
Source File: TCKDuration.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions = {ArithmeticException.class}) public void minusNanos_long_overflowTooBig() { Duration t = Duration.ofSeconds(Long.MAX_VALUE, 999999999); t.minusNanos(-1); }
Example 12
Source File: TCKDuration.java From openjdk-8 with GNU General Public License v2.0 | 4 votes |
@Test public void test_equals_otherClass() { Duration test5 = Duration.ofSeconds(5L, 20); assertEquals(test5.equals(""), false); }
Example 13
Source File: TestDuration.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Test public void minus_zeroReturnsThis() { Duration t = Duration.ofSeconds(1); assertSame(t.minus(Duration.ZERO), t); }
Example 14
Source File: TestDuration.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test public void plusSeconds_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1); assertSame(t.plusSeconds(0), t); }
Example 15
Source File: TCKDuration.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=NullPointerException.class) public void test_compareTo_ObjectNull() { Duration a = Duration.ofSeconds(0L, 0); a.compareTo(null); }
Example 16
Source File: TestDuration.java From openjdk-8-source with GNU General Public License v2.0 | 4 votes |
@Test public void plusSeconds_zeroReturnsThis() { Duration t = Duration.ofSeconds(-1); assertSame(t.plusSeconds(0), t); }
Example 17
Source File: TCKDuration.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
@Test(expectedExceptions=ClassCastException.class) @SuppressWarnings({ "unchecked", "rawtypes" }) public void compareToNonDuration() { Comparable c = Duration.ofSeconds(0L); c.compareTo(new Object()); }
Example 18
Source File: TCKDuration.java From openjdk-8-source with 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 19
Source File: TestDuration.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test public void minusMillis_zeroReturnsThis() { Duration t = Duration.ofSeconds(1, 2000000); assertSame(t.minusMillis(0), t); }
Example 20
Source File: TestDuration.java From hottub with GNU General Public License v2.0 | 4 votes |
@Test public void minusSeconds_zeroReturnsThis() { Duration t = Duration.ofSeconds(1); assertSame(t.minusSeconds(0), t); }