use of java.time.zone.ZoneOffsetTransitionRule in project j2objc by google.
the class TCKZoneOffsetTransitionRule method test_equals_dayOfWeekDifferentNull.
@Test
public void test_equals_dayOfWeekDifferentNull() {
ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of(Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of(Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
assertEquals(a.equals(a), true);
assertEquals(a.equals(b), false);
assertEquals(b.equals(a), false);
assertEquals(b.equals(b), true);
}
use of java.time.zone.ZoneOffsetTransitionRule in project j2objc by google.
the class TCKZoneRules method test_London_nextTransition_lastYear.
public void test_London_nextTransition_lastYear() {
ZoneRules test = europeLondon();
List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
ZoneOffsetTransition zot = rules.get(1).createTransition(Year.MAX_VALUE);
assertEquals(test.nextTransition(zot.getInstant()), null);
}
use of java.time.zone.ZoneOffsetTransitionRule in project j2objc by google.
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.zone.ZoneOffsetTransitionRule in project j2objc by google.
the class TCKZoneRules method test_of.
// -----------------------------------------------------------------------
// of()
// -----------------------------------------------------------------------
public void test_of() {
// used for standard offset
ZoneOffset stdOffset1 = ZoneOffset.UTC;
ZoneOffset stdOffset2 = ZoneOffset.ofHours(1);
LocalDateTime time_of_stdOffsetTransition1 = LocalDateTime.of(2013, 1, 5, 1, 0);
ZoneOffsetTransition stdOffsetTransition1 = ZoneOffsetTransition.of(time_of_stdOffsetTransition1, stdOffset1, stdOffset2);
List<ZoneOffsetTransition> stdOffsetTransition_list = new ArrayList<ZoneOffsetTransition>();
stdOffsetTransition_list.add(stdOffsetTransition1);
// used for wall offset
ZoneOffset wallOffset1 = ZoneOffset.ofHours(2);
ZoneOffset wallOffset2 = ZoneOffset.ofHours(4);
ZoneOffset wallOffset3 = ZoneOffset.ofHours(7);
LocalDateTime time_of_wallOffsetTransition1 = LocalDateTime.of(2013, 2, 5, 1, 0);
LocalDateTime time_of_wallOffsetTransition2 = LocalDateTime.of(2013, 3, 5, 1, 0);
LocalDateTime time_of_wallOffsetTransition3 = LocalDateTime.of(2013, 10, 5, 1, 0);
ZoneOffsetTransition wallOffsetTransition1 = ZoneOffsetTransition.of(time_of_wallOffsetTransition1, wallOffset1, wallOffset2);
ZoneOffsetTransition wallOffsetTransition2 = ZoneOffsetTransition.of(time_of_wallOffsetTransition2, wallOffset2, wallOffset3);
ZoneOffsetTransition wallOffsetTransition3 = ZoneOffsetTransition.of(time_of_wallOffsetTransition3, wallOffset3, wallOffset1);
List<ZoneOffsetTransition> wallOffsetTransition_list = new ArrayList<ZoneOffsetTransition>();
wallOffsetTransition_list.add(wallOffsetTransition1);
wallOffsetTransition_list.add(wallOffsetTransition2);
wallOffsetTransition_list.add(wallOffsetTransition3);
// used for ZoneOffsetTransitionRule
ZoneOffset ruleOffset = ZoneOffset.ofHours(3);
ZoneOffsetTransitionRule.TimeDefinition timeDefinition = ZoneOffsetTransitionRule.TimeDefinition.valueOf("WALL");
ZoneOffsetTransitionRule rule1 = ZoneOffsetTransitionRule.of(Month.FEBRUARY, 2, DayOfWeek.MONDAY, LocalTime.of(1, 0), false, timeDefinition, ZoneOffset.UTC, ZoneOffset.UTC, ruleOffset);
List<ZoneOffsetTransitionRule> rule_list = new ArrayList<ZoneOffsetTransitionRule>();
rule_list.add(rule1);
// Begin verification
ZoneRules zoneRule = ZoneRules.of(stdOffset1, wallOffset1, stdOffsetTransition_list, wallOffsetTransition_list, rule_list);
OffsetDateTime before_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).minusSeconds(1);
OffsetDateTime after_time_of_stdOffsetTransition1 = OffsetDateTime.of(time_of_stdOffsetTransition1, stdOffset1).plusSeconds(1);
;
assertEquals(zoneRule.getStandardOffset(before_time_of_stdOffsetTransition1.toInstant()), stdOffset1);
assertEquals(zoneRule.getStandardOffset(after_time_of_stdOffsetTransition1.toInstant()), stdOffset2);
OffsetDateTime before_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).minusSeconds(1);
OffsetDateTime after_time_of_wallOffsetTransition1 = OffsetDateTime.of(time_of_wallOffsetTransition1, wallOffset1).plusSeconds(1);
assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition1);
assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition1.toInstant()), wallOffsetTransition2);
OffsetDateTime before_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).minusSeconds(1);
OffsetDateTime after_time_of_wallOffsetTransition2 = OffsetDateTime.of(time_of_wallOffsetTransition2, wallOffset2).plusSeconds(1);
assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition2);
assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition2.toInstant()), wallOffsetTransition3);
OffsetDateTime before_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).minusSeconds(1);
OffsetDateTime after_time_of_wallOffsetTransition3 = OffsetDateTime.of(time_of_wallOffsetTransition3, wallOffset3).plusSeconds(1);
assertEquals(zoneRule.nextTransition(before_time_of_wallOffsetTransition3.toInstant()), wallOffsetTransition3);
assertEquals(zoneRule.nextTransition(after_time_of_wallOffsetTransition3.toInstant()), rule1.createTransition(2014));
}
use of java.time.zone.ZoneOffsetTransitionRule in project j2objc by google.
the class TCKZoneOffsetTransitionRuleSerialization method test_serialization_floatingWeekBackwards.
@Test
public void test_serialization_floatingWeekBackwards() throws Exception {
ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of(Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300);
assertSerializable(test);
}
Aggregations