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