use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method factory_of_ints.
//-----------------------------------------------------------------------
// of(int..., ZoneId)
//-----------------------------------------------------------------------
@Test
public void factory_of_ints() {
ZonedDateTime test = ZonedDateTime.of(2008, 6, 30, 11, 30, 10, 500, ZONE_PARIS);
check(test, 2008, 6, 30, 11, 30, 10, 500, OFFSET_0200, ZONE_PARIS);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method test_until_parisLondon.
@Test
public void test_until_parisLondon() {
ZonedDateTime midnightLondon = LocalDate.of(2012, 6, 28).atStartOfDay(ZONE_LONDON);
ZonedDateTime midnightParis1 = LocalDate.of(2012, 6, 29).atStartOfDay(ZONE_PARIS);
ZonedDateTime oneAm1 = LocalDateTime.of(2012, 6, 29, 1, 0).atZone(ZONE_PARIS);
ZonedDateTime midnightParis2 = LocalDate.of(2012, 6, 30).atStartOfDay(ZONE_PARIS);
assertEquals(midnightLondon.until(midnightParis1, HOURS), 23);
assertEquals(midnightLondon.until(oneAm1, HOURS), 24);
assertEquals(midnightLondon.until(midnightParis2, HOURS), 23 + 24);
assertEquals(midnightLondon.until(midnightParis1, DAYS), 0);
assertEquals(midnightLondon.until(oneAm1, DAYS), 1);
assertEquals(midnightLondon.until(midnightParis2, DAYS), 1);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZonedDateTime method factory_ofInstant_Instant_ZR.
//-----------------------------------------------------------------------
// ofInstant(Instant, ZoneId)
//-----------------------------------------------------------------------
@Test
public void factory_ofInstant_Instant_ZR() {
Instant instant = LocalDateTime.of(2008, 6, 30, 11, 30, 10, 35).toInstant(OFFSET_0200);
ZonedDateTime test = ZonedDateTime.ofInstant(instant, ZONE_PARIS);
check(test, 2008, 6, 30, 11, 30, 10, 35, OFFSET_0200, ZONE_PARIS);
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_London_previousTransition_rulesBased.
public void test_London_previousTransition_rulesBased() {
ZoneRules test = europeLondon();
List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
List<ZoneOffsetTransition> trans = test.getTransitions();
ZoneOffsetTransition last = trans.get(trans.size() - 1);
assertEquals(test.previousTransition(last.getInstant().plusSeconds(1)), last);
assertEquals(test.previousTransition(last.getInstant().plusNanos(1)), last);
// Jan 1st of year between transitions and rules
ZonedDateTime odt = ZonedDateTime.ofInstant(last.getInstant(), last.getOffsetAfter());
odt = odt.withDayOfYear(1).plusYears(1).with(LocalTime.MIDNIGHT);
assertEquals(test.previousTransition(odt.toInstant()), last);
// later years
for (int year = 1998; year < 2010; year++) {
ZoneOffsetTransition a = rules.get(0).createTransition(year);
ZoneOffsetTransition b = rules.get(1).createTransition(year);
ZoneOffsetTransition c = rules.get(0).createTransition(year + 1);
assertEquals(test.previousTransition(c.getInstant()), b);
assertEquals(test.previousTransition(b.getInstant().plusSeconds(1)), b);
assertEquals(test.previousTransition(b.getInstant().plusNanos(1)), b);
assertEquals(test.previousTransition(b.getInstant()), a);
assertEquals(test.previousTransition(a.getInstant().plusSeconds(1)), a);
assertEquals(test.previousTransition(a.getInstant().plusNanos(1)), a);
}
}
use of java.time.ZonedDateTime in project jdk8u_jdk by JetBrains.
the class TCKZoneRules method test_Paris_getStandardOffset.
public void test_Paris_getStandardOffset() {
ZoneRules test = europeParis();
ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
while (zdt.getYear() < 2010) {
Instant instant = zdt.toInstant();
if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) {
assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21));
} else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) {
assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
} else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) {
assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
} else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) {
assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
} else {
assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
}
zdt = zdt.plusMonths(6);
}
}
Aggregations