Search in sources :

Example 66 with Instant

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

the class TCKInstant method minusMillis_long_min.

@Test
public void minusMillis_long_min() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND, 1000000);
    i = i.minusMillis(1);
    assertEquals(i.getEpochSecond(), MIN_SECOND);
    assertEquals(i.getNano(), 0);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 67 with Instant

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

the class TCKInstant method test_with_longTemporalField.

@Test(dataProvider = "with_longTemporalField")
public void test_with_longTemporalField(Instant test, TemporalField field, long value, Instant expected, Class<?> expectedEx) {
    if (expectedEx == null) {
        Instant result = test.with(field, value);
        assertEquals(result, expected);
    } else {
        try {
            Instant result = test.with(field, value);
            fail();
        } catch (Exception ex) {
            assertTrue(expectedEx.isInstance(ex));
        }
    }
}
Also used : Instant(java.time.Instant) DateTimeException(java.time.DateTimeException) UnsupportedTemporalTypeException(java.time.temporal.UnsupportedTemporalTypeException) DateTimeParseException(java.time.format.DateTimeParseException) Test(org.testng.annotations.Test)

Example 68 with Instant

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

the class TCKDuration method factory_between_TemporalTemporal_Instant_negated.

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

Example 69 with Instant

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

the class TCKInstant method minusMillis_long_max.

@Test
public void minusMillis_long_max() {
    Instant i = Instant.ofEpochSecond(MAX_SECOND, 998999999);
    i = i.minusMillis(-1);
    assertEquals(i.getEpochSecond(), MAX_SECOND);
    assertEquals(i.getNano(), 999999999);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 70 with Instant

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

the class TCKInstant method plusSeconds_long.

@Test(dataProvider = "PlusSeconds")
public void plusSeconds_long(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant t = Instant.ofEpochSecond(seconds, nanos);
    t = t.plusSeconds(amount);
    assertEquals(t.getEpochSecond(), expectedSeconds);
    assertEquals(t.getNano(), expectedNanoOfSecond);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Aggregations

Instant (java.time.Instant)321 Test (org.testng.annotations.Test)136 Test (org.junit.Test)65 ZonedDateTime (java.time.ZonedDateTime)36 Clock (java.time.Clock)26 OffsetDateTime (java.time.OffsetDateTime)23 LocalDateTime (java.time.LocalDateTime)18 Duration (java.time.Duration)17 LocalDate (java.time.LocalDate)15 IOException (java.io.IOException)11 LocalTime (java.time.LocalTime)11 DateTimeFormatter (java.time.format.DateTimeFormatter)11 Date (java.util.Date)11 Timestamp (java.sql.Timestamp)10 DateTimeFormatterBuilder (java.time.format.DateTimeFormatterBuilder)8 ZoneRules (java.time.zone.ZoneRules)8 MockServerWebExchange (org.springframework.mock.http.server.reactive.test.MockServerWebExchange)8 JsonArray (io.vertx.core.json.JsonArray)7 JsonObject (io.vertx.core.json.JsonObject)7 OffsetTime (java.time.OffsetTime)7