use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_with_adjuster_ensureOffsetDateTimeConsistent.
@Test(dataProvider = "withFieldLong")
public void test_with_adjuster_ensureOffsetDateTimeConsistent(ZonedDateTime base, TemporalField setField, int setValue, ZonedDateTime expected) {
if (setField == OFFSET_SECONDS) {
OffsetDateTime odt = base.toOffsetDateTime().with(setField, setValue);
assertEquals(base.with(odt), expected);
}
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TestOffsetDateTime_instants method factory_ofInstant_minWithMinOffset.
//-----------------------------------------------------------------------
public void factory_ofInstant_minWithMinOffset() {
long days_0000_to_1970 = (146097 * 5) - (30 * 365 + 7);
int year = Year.MIN_VALUE;
long days = (year * 365L + (year / 4 - year / 100 + year / 400)) - days_0000_to_1970;
Instant instant = Instant.ofEpochSecond(days * 24L * 60L * 60L - OFFSET_MIN.getTotalSeconds());
OffsetDateTime test = OffsetDateTime.ofInstant(instant, OFFSET_MIN);
assertEquals(test.getYear(), Year.MIN_VALUE);
assertEquals(test.getMonth().getValue(), 1);
assertEquals(test.getDayOfMonth(), 1);
assertEquals(test.getOffset(), OFFSET_MIN);
assertEquals(test.getHour(), 0);
assertEquals(test.getMinute(), 0);
assertEquals(test.getSecond(), 0);
assertEquals(test.getNano(), 0);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TestOffsetDateTime_instants method test_toEpochSecond_19700101_oneNano.
public void test_toEpochSecond_19700101_oneNano() {
OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 1), ZoneOffset.UTC);
assertEquals(dt.toEpochSecond(), 0);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TestOffsetDateTime_instants method test_toEpochSecond_19700102.
public void test_toEpochSecond_19700102() {
OffsetDateTime dt = OffsetDateTime.of(LocalDate.of(1970, 1, 2), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC);
assertEquals(dt.toEpochSecond(), 24L * 60L * 60L);
}
use of java.time.OffsetDateTime in project jdk8u_jdk by JetBrains.
the class TestOffsetDateTime_instants method factory_ofInstant_allDaysInCycle.
public void factory_ofInstant_allDaysInCycle() {
// sanity check using different algorithm
OffsetDateTime expected = OffsetDateTime.of(LocalDate.of(1970, 1, 1), LocalTime.of(0, 0, 0, 0), ZoneOffset.UTC);
for (long i = 0; i < 146097; i++) {
Instant instant = Instant.ofEpochSecond(i * 24L * 60L * 60L);
OffsetDateTime test = OffsetDateTime.ofInstant(instant, ZoneOffset.UTC);
assertEquals(test, expected);
expected = expected.plusDays(1);
}
}
Aggregations