Search in sources :

Example 61 with Instant

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

the class TCKDuration method factory_between__TemporalTemporal_startNull.

@Test(expectedExceptions = NullPointerException.class)
public void factory_between__TemporalTemporal_startNull() {
    Instant end = Instant.ofEpochSecond(1);
    Duration.between(null, end);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 62 with Instant

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

the class TCKLocalDateTime method now_Clock_allSecsInDay_utc.

@Test
public void now_Clock_allSecsInDay_utc() {
    for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
        Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalDateTime test = LocalDateTime.now(clock);
        assertEquals(test.getYear(), 1970);
        assertEquals(test.getMonth(), Month.JANUARY);
        assertEquals(test.getDayOfMonth(), (i < 24 * 60 * 60 ? 1 : 2));
        assertEquals(test.getHour(), (i / (60 * 60)) % 24);
        assertEquals(test.getMinute(), (i / 60) % 60);
        assertEquals(test.getSecond(), i % 60);
        assertEquals(test.getNano(), 123456789);
    }
}
Also used : LocalDateTime(java.time.LocalDateTime) Instant(java.time.Instant) Clock(java.time.Clock) Test(org.testng.annotations.Test)

Example 63 with Instant

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

the class TCKOffsetTime method factory_ofInstant_beforeEpoch.

@Test
public void factory_ofInstant_beforeEpoch() {
    for (int i = -1; i >= -(24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i, 8);
        OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
        assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
        assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
        assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
        assertEquals(test.getNano(), 8);
    }
}
Also used : OffsetTime(java.time.OffsetTime) Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 64 with Instant

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

the class TCKLocalDate method now_Clock_allSecsInDay_beforeEpoch.

@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
    for (int i = -1; i >= -(2 * 24 * 60 * 60); i--) {
        Instant instant = Instant.ofEpochSecond(i);
        Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
        LocalDate test = LocalDate.now(clock);
        assertEquals(test.getYear(), 1969);
        assertEquals(test.getMonth(), Month.DECEMBER);
        assertEquals(test.getDayOfMonth(), (i >= -24 * 60 * 60 ? 31 : 30));
    }
}
Also used : Instant(java.time.Instant) Clock(java.time.Clock) LocalDate(java.time.LocalDate) Test(org.testng.annotations.Test)

Example 65 with Instant

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

the class TCKInstant method plus_Duration.

@Test(dataProvider = "Plus")
public void plus_Duration(long seconds, int nanos, long otherSeconds, int otherNanos, long expectedSeconds, int expectedNanoOfSecond) {
    Instant i = Instant.ofEpochSecond(seconds, nanos).plus(Duration.ofSeconds(otherSeconds, otherNanos));
    assertEquals(i.getEpochSecond(), expectedSeconds);
    assertEquals(i.getNano(), expectedNanoOfSecond);
}
Also used : 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