Search in sources :

Example 71 with Instant

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

the class TCKInstant method minusSeconds_long.

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

Example 72 with Instant

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

the class TCKInstant method minusMillis_long_overflowTooSmall.

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

Example 73 with Instant

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

the class TCKInstant method test_until_TemporalUnit.

@Test(dataProvider = "periodUntilUnit")
public void test_until_TemporalUnit(long seconds1, int nanos1, long seconds2, long nanos2, TemporalUnit unit, long expected) {
    Instant i1 = Instant.ofEpochSecond(seconds1, nanos1);
    Instant i2 = Instant.ofEpochSecond(seconds2, nanos2);
    long amount = i1.until(i2, unit);
    assertEquals(amount, expected);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 74 with Instant

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

the class TCKInstant method test_get_TemporalField.

//-----------------------------------------------------------------------
// get(TemporalField)
//-----------------------------------------------------------------------
@Test
public void test_get_TemporalField() {
    Instant test = TEST_12345_123456789;
    assertEquals(test.get(ChronoField.NANO_OF_SECOND), 123456789);
    assertEquals(test.get(ChronoField.MICRO_OF_SECOND), 123456);
    assertEquals(test.get(ChronoField.MILLI_OF_SECOND), 123);
}
Also used : Instant(java.time.Instant) Test(org.testng.annotations.Test)

Example 75 with Instant

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

the class TCKInstant method now.

//-----------------------------------------------------------------------
// now()
//-----------------------------------------------------------------------
@Test
public void now() {
    Instant expected = Instant.now(Clock.systemUTC());
    Instant test = Instant.now();
    long diff = Math.abs(test.toEpochMilli() - expected.toEpochMilli());
    // less than 0.1 secs
    assertTrue(diff < 100);
}
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