Search in sources :

Example 71 with Duration

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

the class TCKDuration method factory_between_TemporalTemporal_Instant.

@Test(dataProvider = "durationBetweenInstant")
public void factory_between_TemporalTemporal_Instant(long secs1, int nanos1, long secs2, int nanos2, long expectedSeconds, int expectedNanoOfSecond) {
    Instant start = Instant.ofEpochSecond(secs1, nanos1);
    Instant end = Instant.ofEpochSecond(secs2, nanos2);
    Duration t = Duration.between(start, end);
    assertEquals(t.getSeconds(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
Also used : Instant(java.time.Instant) Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 72 with Duration

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

the class TCKDuration method minusMillis_long.

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

Example 73 with Duration

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

the class TCKDuration method factory_minutes_max.

@Test
public void factory_minutes_max() {
    Duration test = Duration.ofMinutes(Long.MAX_VALUE / 60);
    assertEquals(test.getSeconds(), (Long.MAX_VALUE / 60) * 60);
    assertEquals(test.getNano(), 0);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 74 with Duration

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

the class TCKDuration method factory_parse.

@Test(dataProvider = "parseSuccess")
public void factory_parse(String text, long expectedSeconds, int expectedNanoOfSecond) {
    Duration test = Duration.parse(text);
    assertEquals(test.getSeconds(), expectedSeconds);
    assertEquals(test.getNano(), expectedNanoOfSecond);
}
Also used : Duration(java.time.Duration) Test(org.testng.annotations.Test)

Example 75 with Duration

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

the class TCKDuration method minusNanos_long_overflowTooSmall.

@Test(expectedExceptions = { ArithmeticException.class })
public void minusNanos_long_overflowTooSmall() {
    Duration t = Duration.ofSeconds(Long.MIN_VALUE, 0);
    t.minusNanos(1);
}
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