Search in sources :

Example 76 with Instant

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

the class TCKInstant method test_until_invalidType.

@Test(expectedExceptions = DateTimeException.class)
public void test_until_invalidType() {
    Instant start = Instant.ofEpochSecond(12, 3000);
    start.until(LocalTime.of(11, 30), SECONDS);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 77 with Instant

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

the class TCKInstant method factory_seconds_long_long_nanosNegativeAdjusted.

@Test
public void factory_seconds_long_long_nanosNegativeAdjusted() {
    Instant test = Instant.ofEpochSecond(2L, -1);
    assertEquals(test.getEpochSecond(), 1);
    assertEquals(test.getNano(), 999999999);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 78 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 79 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 80 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)

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