Search in sources :

Example 81 with Duration

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

the class TCKDuration method minusMillis_long_min.

@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);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 82 with Duration

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

the class TCKDuration method plus_longTemporalUnit_null.

@Test(expectedExceptions = NullPointerException.class)
public void plus_longTemporalUnit_null() {
    Duration t = Duration.ofSeconds(1);
    t.plus(1, (TemporalUnit) null);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 83 with Duration

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

the class TCKDuration method factory_nanos_nanos.

//-----------------------------------------------------------------------
// ofNanos(long)
//-----------------------------------------------------------------------
@Test
public void factory_nanos_nanos() {
    Duration test = Duration.ofNanos(1);
    assertEquals(test.getSeconds(), 0);
    assertEquals(test.getNano(), 1);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 84 with Duration

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

the class TCKDuration method plusDays_long.

@Test(dataProvider = "PlusDays")
public void plusDays_long(long days, long amount, long expectedDays) {
    Duration t = Duration.ofDays(days);
    t = t.plusDays(amount);
    assertEquals(t.toDays(), expectedDays);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 85 with Duration

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

the class TCKDuration method test_getUnit.

@Test()
public void test_getUnit() {
    Duration test = Duration.ofSeconds(2000, 1000);
    long seconds = test.get(ChronoUnit.SECONDS);
    assertEquals(seconds, 2000, "duration.get(SECONDS)");
    long nanos = test.get(ChronoUnit.NANOS);
    assertEquals(nanos, 1000, "duration.get(NANOS)");
}
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