public void test_London_getTransitionRules() { ZoneRules test = europeLondon(); List<ZoneOffsetTransitionRule> rules = test.getTransitionRules(); assertEquals(rules.size(), 2); ZoneOffsetTransitionRule in = rules.get(0); assertEquals(in.getMonth(), Month.MARCH); assertEquals(in.getDayOfMonthIndicator(), 25); // optimized from -1 assertEquals(in.getDayOfWeek(), DayOfWeek.SUNDAY); assertEquals(in.getLocalTime(), LocalTime.of(1, 0)); assertEquals(in.getTimeDefinition(), TimeDefinition.UTC); assertEquals(in.getStandardOffset(), OFFSET_ZERO); assertEquals(in.getOffsetBefore(), OFFSET_ZERO); assertEquals(in.getOffsetAfter(), OFFSET_PONE); ZoneOffsetTransitionRule out = rules.get(1); assertEquals(out.getMonth(), Month.OCTOBER); assertEquals(out.getDayOfMonthIndicator(), 25); // optimized from -1 assertEquals(out.getDayOfWeek(), DayOfWeek.SUNDAY); assertEquals(out.getLocalTime(), LocalTime.of(1, 0)); assertEquals(out.getTimeDefinition(), TimeDefinition.UTC); assertEquals(out.getStandardOffset(), OFFSET_ZERO); assertEquals(out.getOffsetBefore(), OFFSET_PONE); assertEquals(out.getOffsetAfter(), OFFSET_ZERO); }
@Test public void test_toString_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day of MARCH at 01:00 WALL, standard offset +02:00]"); }
TimeDefinition parseTimeDefinition(char c) { switch (c) { case 's': case 'S': // standard time return TimeDefinition.STANDARD; case 'u': case 'U': case 'g': case 'G': case 'z': case 'Z': // UTC return TimeDefinition.UTC; case 'w': case 'W': default: // wall time return TimeDefinition.WALL; } }
@Test public void test_serialization_unusualOffsets() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, ZoneOffset.ofHoursMinutesSeconds(-12, -20, -50), ZoneOffset.ofHoursMinutesSeconds(-4, -10, -34), ZoneOffset.ofHours(-18)); assertSerializable(test); }
@Test public void test_serialization_endOfDay() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.FRIDAY, LocalTime.MIDNIGHT, true, TimeDefinition.UTC, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertSerializable(test); }
@Test public void test_serialization_unusualTime() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.WEDNESDAY, LocalTime.of(13, 34, 56), false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertSerializable(test); }
@Test public void test_serialization_floatingWeek() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertSerializable(test); }
@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); }
@Test public void test_serialization_fixedDate() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertSerializable(test); }
@Test public void test_getters_floatingWeek() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(test.getMonth(), Month.MARCH); assertEquals(test.getDayOfMonthIndicator(), 20); assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY); assertEquals(test.getLocalTime(), TIME_0100); assertEquals(test.isMidnightEndOfDay(), false); assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); assertEquals(test.getStandardOffset(), OFFSET_0200); assertEquals(test.getOffsetBefore(), OFFSET_0200); assertEquals(test.getOffsetAfter(), OFFSET_0300); }
@Test public void test_getters_floatingWeekBackwards() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(test.getMonth(), Month.MARCH); assertEquals(test.getDayOfMonthIndicator(), -1); assertEquals(test.getDayOfWeek(), DayOfWeek.SUNDAY); assertEquals(test.getLocalTime(), TIME_0100); assertEquals(test.isMidnightEndOfDay(), false); assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); assertEquals(test.getStandardOffset(), OFFSET_0200); assertEquals(test.getOffsetBefore(), OFFSET_0200); assertEquals(test.getOffsetAfter(), OFFSET_0300); }
@Test public void test_getters_fixedDate() throws Exception { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(test.getMonth(), Month.MARCH); assertEquals(test.getDayOfMonthIndicator(), 20); assertEquals(test.getDayOfWeek(), null); assertEquals(test.getLocalTime(), TIME_0100); assertEquals(test.isMidnightEndOfDay(), false); assertEquals(test.getTimeDefinition(), TimeDefinition.WALL); assertEquals(test.getStandardOffset(), OFFSET_0200); assertEquals(test.getOffsetBefore(), OFFSET_0200); assertEquals(test.getOffsetAfter(), OFFSET_0300); }
@Test public void test_createTransition_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
@Test public void test_createTransition_floatingWeek_overlap_endOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 27, 0, 0), OFFSET_0300, OFFSET_0200); assertEquals(test.createTransition(2000), trans); }
@Test public void test_createTransition_floatingWeekBackwards_last() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
@Test public void test_createTransition_floatingWeekBackwards_seventhLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -7, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 19, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
@Test public void test_createTransition_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 26, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
@Test public void test_createTransition_fixedDate() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransition trans = ZoneOffsetTransition.of( LocalDateTime.of(2000, Month.MARCH, 20, 1, 0), OFFSET_0200, OFFSET_0300); assertEquals(test.createTransition(2000), trans); }
@Test public void test_equals_monthDifferent() { 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.APRIL, 20, DayOfWeek.SUNDAY, 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); }
@Test public void test_equals_dayOfMonthDifferent() { 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, 21, DayOfWeek.SUNDAY, 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); }
@Test public void test_equals_dayOfWeekDifferent() { 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, DayOfWeek.SATURDAY, 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); }
@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); }
@Test public void test_equals_localTimeDifferent() { 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, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, 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); }
@Test public void test_equals_endOfDayDifferent() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, 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); }
@Test public void test_equals_timeDefinitionDifferent() { 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, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.STANDARD, 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); }
@Test public void test_equals_standardOffsetDifferent() { 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, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0300, OFFSET_0200, OFFSET_0300); assertEquals(a.equals(a), true); assertEquals(a.equals(b), false); assertEquals(b.equals(a), false); assertEquals(b.equals(b), true); }
@Test public void test_equals_offsetBeforeDifferent() { 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, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0300); assertEquals(a.equals(a), true); assertEquals(a.equals(b), false); assertEquals(b.equals(a), false); assertEquals(b.equals(b), true); }
@Test public void test_equals_offsetAfterDifferent() { 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, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0200); assertEquals(a.equals(a), true); assertEquals(a.equals(b), false); assertEquals(b.equals(a), false); assertEquals(b.equals(b), true); }
@Test public void test_equals_string_false() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(a.equals("TZDB"), false); }
@Test public void test_equals_null_false() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(a.equals(null), false); }
@Test public void test_hashCode_floatingWeek_gap_notEndOfDay() { 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, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(a.hashCode(), b.hashCode()); }
@Test public void test_hashCode_floatingWeek_overlap_endOfDay_nullDayOfWeek() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, null, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); assertEquals(a.hashCode(), b.hashCode()); }
@Test public void test_hashCode_floatingWeekBackwards() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, -1, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(a.hashCode(), b.hashCode()); }
@Test public void test_hashCode_fixedDate() { ZoneOffsetTransitionRule a = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); ZoneOffsetTransitionRule b = ZoneOffsetTransitionRule.of( Month.MARCH, 20, null, TIME_0100, false, TimeDefinition.STANDARD, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(a.hashCode(), b.hashCode()); }
@Test public void test_toString_floatingWeek_gap_notEndOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, 20, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or after MARCH 20 at 01:00 WALL, standard offset +02:00]"); }
@Test public void test_toString_floatingWeek_overlap_endOfDay() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.OCTOBER, 20, DayOfWeek.SUNDAY, LocalTime.MIDNIGHT, true, TimeDefinition.WALL, OFFSET_0200, OFFSET_0300, OFFSET_0200); assertEquals(test.toString(), "TransitionRule[Overlap +03:00 to +02:00, SUNDAY on or after OCTOBER 20 at 24:00 WALL, standard offset +02:00]"); }
@Test public void test_toString_floatingWeekBackwards_secondLast() { ZoneOffsetTransitionRule test = ZoneOffsetTransitionRule.of( Month.MARCH, -2, DayOfWeek.SUNDAY, TIME_0100, false, TimeDefinition.WALL, OFFSET_0200, OFFSET_0200, OFFSET_0300); assertEquals(test.toString(), "TransitionRule[Gap +02:00 to +03:00, SUNDAY on or before last day minus 1 of MARCH at 01:00 WALL, standard offset +02:00]"); }