java.time.zone.ZoneOffsetTransitionRule Java Examples

The following examples show how to use java.time.zone.ZoneOffsetTransitionRule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TCKZoneRules.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: TCKZoneRules.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public void test_London_nextTransition_rulesBased() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition last = trans.get(trans.size() - 1);
    assertEquals(test.nextTransition(last.getInstant()), rules.get(0).createTransition(1998));

    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.nextTransition(a.getInstant()), b);
        assertEquals(test.nextTransition(b.getInstant().minusNanos(1)), b);

        assertEquals(test.nextTransition(b.getInstant()), c);
        assertEquals(test.nextTransition(c.getInstant().minusNanos(1)), c);
    }
}
 
Example #3
Source File: TCKZoneRules.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #4
Source File: TCKZoneRules.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: TCKZoneRules.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public void test_London_nextTransition_rulesBased() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransitionRule> rules = test.getTransitionRules();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition last = trans.get(trans.size() - 1);
    assertEquals(test.nextTransition(last.getInstant()), rules.get(0).createTransition(1998));

    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.nextTransition(a.getInstant()), b);
        assertEquals(test.nextTransition(b.getInstant().minusNanos(1)), b);

        assertEquals(test.nextTransition(b.getInstant()), c);
        assertEquals(test.nextTransition(c.getInstant().minusNanos(1)), c);
    }
}
 
Example #6
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #7
Source File: TCKZoneOffsetTransitionRule.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: TCKZoneOffsetTransitionRuleSerialization.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #9
Source File: TCKZoneOffsetTransitionRule.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #10
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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());
}
 
Example #11
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #12
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #13
Source File: TzdbZoneRulesProvider.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Converts this to a transition rule.
 *
 * @param standardOffset  the active standard offset, not null
 * @param savingsBeforeSecs  the active savings before the transition in seconds
 * @return the transition, not null
*/
ZoneOffsetTransitionRule toTransitionRule(ZoneOffset stdOffset, int savingsBefore) {
    // rule shared by different zones, so don't change it
    Month month = this.month;
    int dayOfMonth = this.dayOfMonth;
    DayOfWeek dayOfWeek = this.dayOfWeek;
    boolean endOfDay = this.endOfDay;

    // optimize stored format
    if (dayOfMonth < 0) {
        if (month != Month.FEBRUARY) {    // not Month.FEBRUARY
            dayOfMonth = month.maxLength() - 6;
        }
    }
    if (endOfDay && dayOfMonth > 0 &&
        (dayOfMonth == 28 && month == Month.FEBRUARY) == false) {
        LocalDate date = LocalDate.of(2004, month, dayOfMonth).plusDays(1);  // leap-year
        month = date.getMonth();
        dayOfMonth = date.getDayOfMonth();
        if (dayOfWeek != null) {
            dayOfWeek = dayOfWeek.plus(1);
        }
        endOfDay = false;
    }
    // build rule
    return ZoneOffsetTransitionRule.of(
            //month, dayOfMonth, dayOfWeek, time, endOfDay, timeDefinition,
            month, dayOfMonth, dayOfWeek,
            LocalTime.ofSecondOfDay(secsOfDay), endOfDay, timeDefinition,
            stdOffset,
            ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsBefore),
            ZoneOffset.ofTotalSeconds(stdOffset.getTotalSeconds() + savingsAmount));
}
 
Example #14
Source File: TCKZoneOffsetTransitionRule.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #15
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #16
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #17
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #18
Source File: TCKZoneOffsetTransitionRuleSerialization.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #19
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #20
Source File: TCKZoneRules.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
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);
    }
}
 
Example #21
Source File: TCKZoneOffsetTransitionRule.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@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());
}
 
Example #22
Source File: TCKZoneOffsetTransitionRule.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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]");
}
 
Example #23
Source File: TCKZoneOffsetTransitionRule.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@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]");
}
 
Example #24
Source File: TCKZoneOffsetTransitionRule.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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());
}
 
Example #25
Source File: TCKZoneOffsetTransitionRule.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #26
Source File: TCKZoneOffsetTransitionRule.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #27
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #28
Source File: TCKZoneOffsetTransitionRule.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #29
Source File: TCKZoneOffsetTransitionRule.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #30
Source File: TCKZoneOffsetTransitionRule.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@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);
}