Search in sources :

Example 81 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 82 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)

Example 83 with Instant

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

the class TCKInstant method plus_longTemporalUnit_overflowTooSmall.

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

Example 84 with Instant

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

the class TCKZonedDateTime method factory_ofInstant_maxInstantWithMaxOffset.

//-----------------------------------------------------------------------
@Test(expectedExceptions = DateTimeException.class)
public void factory_ofInstant_maxInstantWithMaxOffset() {
    Instant instant = Instant.ofEpochSecond(Long.MAX_VALUE);
    ZonedDateTime.ofInstant(instant, OFFSET_MAX);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 85 with Instant

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

the class TCKZonedDateTime method now_Clock_allSecsInDay_zone.

@Test
public void now_Clock_allSecsInDay_zone() {
    ZoneId zone = ZoneId.of("Europe/London");
    for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
        Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
        ZonedDateTime expected = ZonedDateTime.ofInstant(instant, zone);
        Clock clock = Clock.fixed(expected.toInstant(), zone);
        ZonedDateTime test = ZonedDateTime.now(clock);
        assertEquals(test, expected);
    }
}
Also used : ZoneId(java.time.ZoneId) ZonedDateTime(java.time.ZonedDateTime) Instant(java.time.Instant) Clock(java.time.Clock) Test(org.testng.annotations.Test)

Aggregations

Instant (java.time.Instant)463 Test (org.testng.annotations.Test)143 Test (org.junit.Test)85 ZonedDateTime (java.time.ZonedDateTime)39 Duration (java.time.Duration)30 Clock (java.time.Clock)26 Lifetime (org.apache.cxf.sts.request.Lifetime)26 OffsetDateTime (java.time.OffsetDateTime)23 LocalDateTime (java.time.LocalDateTime)20 ArrayList (java.util.ArrayList)18 Element (org.w3c.dom.Element)18 LocalDate (java.time.LocalDate)17 IOException (java.io.IOException)14 Date (java.util.Date)14 LocalTime (java.time.LocalTime)12 DateTimeFormatter (java.time.format.DateTimeFormatter)12 STSException (org.apache.cxf.ws.security.sts.provider.STSException)12 SecurityToken (org.apache.cxf.ws.security.tokenstore.SecurityToken)12 Timestamp (java.sql.Timestamp)11 DefaultConditionsProvider (org.apache.cxf.sts.token.provider.DefaultConditionsProvider)10