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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations