use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKDuration method factory_between__TemporalTemporal_startNull.
@Test(expectedExceptions = NullPointerException.class)
public void factory_between__TemporalTemporal_startNull() {
Instant end = Instant.ofEpochSecond(1);
Duration.between(null, end);
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKLocalDateTime method now_Clock_allSecsInDay_utc.
@Test
public void now_Clock_allSecsInDay_utc() {
for (int i = 0; i < (2 * 24 * 60 * 60); i++) {
Instant instant = Instant.ofEpochSecond(i).plusNanos(123456789L);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
LocalDateTime test = LocalDateTime.now(clock);
assertEquals(test.getYear(), 1970);
assertEquals(test.getMonth(), Month.JANUARY);
assertEquals(test.getDayOfMonth(), (i < 24 * 60 * 60 ? 1 : 2));
assertEquals(test.getHour(), (i / (60 * 60)) % 24);
assertEquals(test.getMinute(), (i / 60) % 60);
assertEquals(test.getSecond(), i % 60);
assertEquals(test.getNano(), 123456789);
}
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKOffsetTime method factory_ofInstant_beforeEpoch.
@Test
public void factory_ofInstant_beforeEpoch() {
for (int i = -1; i >= -(24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i, 8);
OffsetTime test = OffsetTime.ofInstant(instant, ZoneOffset.UTC);
assertEquals(test.getHour(), ((i + 24 * 60 * 60) / (60 * 60)) % 24);
assertEquals(test.getMinute(), ((i + 24 * 60 * 60) / 60) % 60);
assertEquals(test.getSecond(), (i + 24 * 60 * 60) % 60);
assertEquals(test.getNano(), 8);
}
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKLocalDate method now_Clock_allSecsInDay_beforeEpoch.
@Test
public void now_Clock_allSecsInDay_beforeEpoch() {
for (int i = -1; i >= -(2 * 24 * 60 * 60); i--) {
Instant instant = Instant.ofEpochSecond(i);
Clock clock = Clock.fixed(instant, ZoneOffset.UTC);
LocalDate test = LocalDate.now(clock);
assertEquals(test.getYear(), 1969);
assertEquals(test.getMonth(), Month.DECEMBER);
assertEquals(test.getDayOfMonth(), (i >= -24 * 60 * 60 ? 31 : 30));
}
}
use of java.time.Instant in project jdk8u_jdk by JetBrains.
the class TCKInstant method plus_Duration.
@Test(dataProvider = "Plus")
public void plus_Duration(long seconds, int nanos, long otherSeconds, int otherNanos, long expectedSeconds, int expectedNanoOfSecond) {
Instant i = Instant.ofEpochSecond(seconds, nanos).plus(Duration.ofSeconds(otherSeconds, otherNanos));
assertEquals(i.getEpochSecond(), expectedSeconds);
assertEquals(i.getNano(), expectedNanoOfSecond);
}
Aggregations