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