Search in sources :

Example 56 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method plusMillis_long_overflowTooSmall.

@Test(expectedExceptions = { ArithmeticException.class })
public void plusMillis_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0);
    t.plusMillis(-1);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 57 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method plusMillis_long_max.

@Test
public void plusMillis_long_max() {
    Duration t = Duration.ofSeconds(Long.MAX_VALUE, 998999999);
    t = t.plusMillis(1);
    assertEquals(t.getSeconds(), Long.MAX_VALUE);
    assertEquals(t.getNano(), 999999999);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 58 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKDuration method plus_longTemporalUnit_seconds.

//-----------------------------------------------------------------------
@Test
public void plus_longTemporalUnit_seconds() {
    Duration t = Duration.ofSeconds(1);
    t = t.plus(1, SECONDS);
    assertEquals(2, t.getSeconds());
    assertEquals(0, t.getNano());
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 59 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKOffsetDateTime method test_plus_Duration.

//-----------------------------------------------------------------------
// plus(Duration)
//-----------------------------------------------------------------------
@Test
public void test_plus_Duration() {
    Duration dur = Duration.ofSeconds(62, 3);
    OffsetDateTime t = TEST_2008_6_30_11_30_59_000000500.plus(dur);
    assertEquals(t, OffsetDateTime.of(2008, 6, 30, 11, 32, 1, 503, OFFSET_PONE));
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 60 with Duration

use of java.time.Duration in project jdk8u_jdk by JetBrains.

the class TCKZonedDateTime method test_minus_TemporalAmount_Duration.

@Test
public void test_minus_TemporalAmount_Duration() {
    Duration duration = Duration.ofSeconds(4L * 60 * 60 + 5L * 60 + 6L);
    ZonedDateTime t = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 12, 30, 59, 500), ZONE_0100);
    ZonedDateTime expected = ZonedDateTime.of(LocalDateTime.of(2008, 6, 1, 8, 25, 53, 500), ZONE_0100);
    assertEquals(t.minus(duration), expected);
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Duration(java.time.Duration) Test(org.testng.annotations.Test)

Aggregations

Duration (java.time.Duration)262 Test (org.testng.annotations.Test)135 Test (org.junit.Test)32 Instant (java.time.Instant)27 ArrayList (java.util.ArrayList)15 CompletableFuture (java.util.concurrent.CompletableFuture)15 Preconditions (com.google.common.base.Preconditions)14 Exceptions (io.pravega.common.Exceptions)13 List (java.util.List)13 CompletionException (java.util.concurrent.CompletionException)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 TimeoutTimer (io.pravega.common.TimeoutTimer)12 Futures (io.pravega.common.concurrent.Futures)12 SegmentProperties (io.pravega.segmentstore.contracts.SegmentProperties)11 StreamSegmentNotExistsException (io.pravega.segmentstore.contracts.StreamSegmentNotExistsException)11 Storage (io.pravega.segmentstore.storage.Storage)11 LoggerHelpers (io.pravega.common.LoggerHelpers)10 ZonedDateTime (java.time.ZonedDateTime)10 Executor (java.util.concurrent.Executor)10 Slf4j (lombok.extern.slf4j.Slf4j)10