Search in sources :

Example 36 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 37 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 38 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 39 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)

Example 40 with Duration

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

the class TestDuration method plusNanos_zeroReturnsThis.

@Test
public void plusNanos_zeroReturnsThis() {
    Duration t = Duration.ofSeconds(-1, 2000000);
    assertSame(t.plusNanos(0), t);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Aggregations

Duration (java.time.Duration)1205 Test (org.junit.Test)418 Test (org.testng.annotations.Test)139 Instant (java.time.Instant)128 Test (org.junit.jupiter.api.Test)83 List (java.util.List)82 ArrayList (java.util.ArrayList)81 CompletableFuture (java.util.concurrent.CompletableFuture)81 Collectors (java.util.stream.Collectors)73 Collections (java.util.Collections)62 Preconditions (com.google.common.base.Preconditions)61 Map (java.util.Map)60 Slf4j (lombok.extern.slf4j.Slf4j)59 lombok.val (lombok.val)55 HashMap (java.util.HashMap)54 Arrays (java.util.Arrays)52 Function (java.util.function.Function)51 IOException (java.io.IOException)49 HashSet (java.util.HashSet)47 TimeUnit (java.util.concurrent.TimeUnit)47