Search in sources :

Example 96 with Instant

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

the class TCKInstant method minus_longTemporalUnit_overflowTooSmall.

@Test(expectedExceptions = DateTimeException.class)
public void minus_longTemporalUnit_overflowTooSmall() {
    Instant i = Instant.ofEpochSecond(MIN_SECOND);
    i.minus(1, NANOS);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 97 with Instant

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

the class TCKInstant method minusSeconds_long_overflowTooBig.

@Test(expectedExceptions = { ArithmeticException.class })
public void minusSeconds_long_overflowTooBig() {
    Instant i = Instant.ofEpochSecond(1, 0);
    i.minusSeconds(Long.MIN_VALUE + 1);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 98 with Instant

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

the class TCKInstant method test_atOffset.

//-----------------------------------------------------------------------
// atOffset()
//-----------------------------------------------------------------------
@Test
public void test_atOffset() {
    for (int i = 0; i < (24 * 60 * 60); i++) {
        Instant instant = Instant.ofEpochSecond(i);
        OffsetDateTime test = instant.atOffset(ZoneOffset.ofHours(1));
        assertEquals(test.getYear(), 1970);
        assertEquals(test.getMonthValue(), 1);
        assertEquals(test.getDayOfMonth(), 1 + (i >= 23 * 60 * 60 ? 1 : 0));
        assertEquals(test.getHour(), ((i / (60 * 60)) + 1) % 24);
        assertEquals(test.getMinute(), (i / 60) % 60);
        assertEquals(test.getSecond(), i % 60);
    }
}
Also used : OffsetDateTime(java.time.OffsetDateTime) Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 99 with Instant

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

the class TCKInstant method minusMillis_long_minusOneLess.

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

Example 100 with Instant

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

the class TCKInstant method minusMillis_long_oneMore.

@Test(dataProvider = "MinusMillis")
public void minusMillis_long_oneMore(long seconds, int nanos, long amount, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds + 1, nanos);
    i = i.minusMillis(amount);
    assertEquals(i.getEpochSecond(), expectedSeconds + 1);
    assertEquals(i.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