Search in sources :

Example 46 with Duration

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

the class TCKDuration method minusMillis_long_oneMore.

@Test(dataProvider = "MinusMillis")
public void minusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds + 1, nanos);
    t = t.minusMillis(amount);
    assertEquals(t.getSeconds(), expectedSeconds + 1);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 47 with Duration

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

the class TCKDuration method test_equals_otherClass.

@Test
public void test_equals_otherClass() {
    Duration test5 = Duration.ofSeconds(5L, 20);
    assertEquals(test5.equals(""), false);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 48 with Duration

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

the class TCKDuration method minusMillis_long_minusOneLess.

@Test(dataProvider = "MinusMillis")
public void minusMillis_long_minusOneLess(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Duration t = Duration.ofSeconds(seconds - 1, nanos);
    t = t.minusMillis(amount);
    assertEquals(t.getSeconds(), expectedSeconds - 1);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 49 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 50 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)195 Test (org.testng.annotations.Test)135 Instant (java.time.Instant)17 Test (org.junit.Test)16 List (java.util.List)6 Map (java.util.Map)4 ZonedDateTime (java.time.ZonedDateTime)3 ArrayList (java.util.ArrayList)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 ReplSetHeartbeatReply (com.torodb.mongodb.commands.signatures.internal.ReplSetHeartbeatReply)2 LocalDateTime (java.time.LocalDateTime)2 OffsetDateTime (java.time.OffsetDateTime)2 ZoneId (java.time.ZoneId)2 DateTimeFormatter (java.time.format.DateTimeFormatter)2 Iterator (java.util.Iterator)2 Optional (java.util.Optional)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Collectors (java.util.stream.Collectors)2 Edge (org.apache.tinkerpop.gremlin.structure.Edge)2 JSONLexer (com.alibaba.fastjson.parser.JSONLexer)1