use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKInstant method test_until_invalidType.
@Test(expectedExceptions = DateTimeException.class)
public void test_until_invalidType() {
Instant start = Instant.ofEpochSecond(12, 3000);
start.until(LocalTime.of(11, 30), SECONDS);
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKInstant method factory_seconds_long_long_nanosNegativeAdjusted.
@Test
public void factory_seconds_long_long_nanosNegativeAdjusted() {
Instant test = Instant.ofEpochSecond(2L, -1);
assertEquals(test.getEpochSecond(), 1);
assertEquals(test.getNano(), 999999999);
}
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);
}
}
Aggregations