Java Code Examples for java.time.zone.ZoneRules#getTransitions()

The following examples show how to use java.time.zone.ZoneRules#getTransitions() . 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 hottub 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 2
Source File: TCKZoneRules.java    From jdk8u-jdk 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_previousTransition_historic() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.previousTransition(first.getInstant()), null);
    assertEquals(test.previousTransition(first.getInstant().minusNanos(1)), null);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition prev = trans.get(i);
        ZoneOffsetTransition cur = trans.get(i + 1);

        assertEquals(test.previousTransition(cur.getInstant()), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusSeconds(1)), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusNanos(1)), prev);
    }
}
 
Example 4
Source File: TCKZoneRules.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public void test_London_previousTransition_historic() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.previousTransition(first.getInstant()), null);
    assertEquals(test.previousTransition(first.getInstant().minusNanos(1)), null);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition prev = trans.get(i);
        ZoneOffsetTransition cur = trans.get(i + 1);

        assertEquals(test.previousTransition(cur.getInstant()), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusSeconds(1)), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusNanos(1)), prev);
    }
}
 
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_previousTransition_historic() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.previousTransition(first.getInstant()), null);
    assertEquals(test.previousTransition(first.getInstant().minusNanos(1)), null);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition prev = trans.get(i);
        ZoneOffsetTransition cur = trans.get(i + 1);

        assertEquals(test.previousTransition(cur.getInstant()), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusSeconds(1)), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusNanos(1)), prev);
    }
}
 
Example 6
Source File: TCKZoneRules.java    From jdk8u-jdk 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 7
Source File: TCKZoneRules.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public void test_London_previousTransition_historic() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.previousTransition(first.getInstant()), null);
    assertEquals(test.previousTransition(first.getInstant().minusNanos(1)), null);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition prev = trans.get(i);
        ZoneOffsetTransition cur = trans.get(i + 1);

        assertEquals(test.previousTransition(cur.getInstant()), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusSeconds(1)), prev);
        assertEquals(test.previousTransition(prev.getInstant().plusNanos(1)), prev);
    }
}
 
Example 8
Source File: TCKZoneRules.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void test_Apia_nextTransition_historic() {
    ZoneRules test = pacificApia();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition cur = trans.get(i);
        ZoneOffsetTransition next = trans.get(i + 1);

        assertEquals(test.nextTransition(cur.getInstant()), next);
        assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next);
    }
}
 
Example 9
Source File: TCKZoneRules.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void test_Apia_nextTransition_historic() {
    ZoneRules test = pacificApia();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition cur = trans.get(i);
        ZoneOffsetTransition next = trans.get(i + 1);

        assertEquals(test.nextTransition(cur.getInstant()), next);
        assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next);
    }
}
 
Example 10
Source File: TCKZoneRules.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void test_Apia_nextTransition_historic() {
    ZoneRules test = pacificApia();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition cur = trans.get(i);
        ZoneOffsetTransition next = trans.get(i + 1);

        assertEquals(test.nextTransition(cur.getInstant()), next);
        assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next);
    }
}
 
Example 11
Source File: TCKZoneRules.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void test_Kathmandu_nextTransition_historic() {
    ZoneRules test = asiaKathmandu();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition cur = trans.get(i);
        ZoneOffsetTransition next = trans.get(i + 1);

        assertEquals(test.nextTransition(cur.getInstant()), next);
        assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next);
    }
}
 
Example 12
Source File: TCKZoneRules.java    From openjdk-8-source 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 13
Source File: TCKZoneRules.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void test_Kathmandu_nextTransition_noRules() {
    ZoneRules test = asiaKathmandu();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition last = trans.get(trans.size() - 1);
    assertEquals(test.nextTransition(last.getInstant()), null);
}
 
Example 14
Source File: TCKZoneRules.java    From hottub 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 15
Source File: TCKZoneRules.java    From dragonwell8_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 16
Source File: TCKZoneRules.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void test_Kathmandu_nextTransition_historic() {
    ZoneRules test = asiaKathmandu();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition cur = trans.get(i);
        ZoneOffsetTransition next = trans.get(i + 1);

        assertEquals(test.nextTransition(cur.getInstant()), next);
        assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next);
    }
}
 
Example 17
Source File: TCKZoneRules.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void test_London_nextTransition_historic() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(test.nextTransition(first.getInstant().minusNanos(1)), first);

    for (int i = 0; i < trans.size() - 1; i++) {
        ZoneOffsetTransition cur = trans.get(i);
        ZoneOffsetTransition next = trans.get(i + 1);

        assertEquals(test.nextTransition(cur.getInstant()), next);
        assertEquals(test.nextTransition(next.getInstant().minusNanos(1)), next);
    }
}
 
Example 18
Source File: TCKZoneRules.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
public void test_London_getTransitions() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(first.getDateTimeBefore(), LocalDateTime.of(1847, 12, 1, 0, 0));
    assertEquals(first.getOffsetBefore(), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15));
    assertEquals(first.getOffsetAfter(), OFFSET_ZERO);

    ZoneOffsetTransition spring1916 = trans.get(1);
    assertEquals(spring1916.getDateTimeBefore(), LocalDateTime.of(1916, 5, 21, 2, 0));
    assertEquals(spring1916.getOffsetBefore(), OFFSET_ZERO);
    assertEquals(spring1916.getOffsetAfter(), OFFSET_PONE);

    ZoneOffsetTransition autumn1916 = trans.get(2);
    assertEquals(autumn1916.getDateTimeBefore(), LocalDateTime.of(1916, 10, 1, 3, 0));
    assertEquals(autumn1916.getOffsetBefore(), OFFSET_PONE);
    assertEquals(autumn1916.getOffsetAfter(), OFFSET_ZERO);

    ZoneOffsetTransition zot = null;
    Iterator<ZoneOffsetTransition> it = trans.iterator();
    while (it.hasNext()) {
        zot = it.next();
        if (zot.getDateTimeBefore().getYear() == 1990) {
            break;
        }
    }
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 3, 25, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 10, 28, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 3, 31, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 10, 27, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 3, 29, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 10, 25, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 3, 28, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 10, 24, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 3, 27, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 10, 23, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 3, 26, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 10, 22, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 3, 31, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 10, 27, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 3, 30, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 10, 26, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    assertEquals(it.hasNext(), false);
}
 
Example 19
Source File: TCKZoneRules.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public void test_London_getTransitions() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(first.getDateTimeBefore(), LocalDateTime.of(1847, 12, 1, 0, 0));
    assertEquals(first.getOffsetBefore(), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15));
    assertEquals(first.getOffsetAfter(), OFFSET_ZERO);

    ZoneOffsetTransition spring1916 = trans.get(1);
    assertEquals(spring1916.getDateTimeBefore(), LocalDateTime.of(1916, 5, 21, 2, 0));
    assertEquals(spring1916.getOffsetBefore(), OFFSET_ZERO);
    assertEquals(spring1916.getOffsetAfter(), OFFSET_PONE);

    ZoneOffsetTransition autumn1916 = trans.get(2);
    assertEquals(autumn1916.getDateTimeBefore(), LocalDateTime.of(1916, 10, 1, 3, 0));
    assertEquals(autumn1916.getOffsetBefore(), OFFSET_PONE);
    assertEquals(autumn1916.getOffsetAfter(), OFFSET_ZERO);

    ZoneOffsetTransition zot = null;
    Iterator<ZoneOffsetTransition> it = trans.iterator();
    while (it.hasNext()) {
        zot = it.next();
        if (zot.getDateTimeBefore().getYear() == 1990) {
            break;
        }
    }
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 3, 25, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 10, 28, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 3, 31, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 10, 27, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 3, 29, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 10, 25, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 3, 28, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 10, 24, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 3, 27, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 10, 23, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 3, 26, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 10, 22, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 3, 31, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 10, 27, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 3, 30, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 10, 26, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    assertEquals(it.hasNext(), false);
}
 
Example 20
Source File: TCKZoneRules.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
public void test_London_getTransitions() {
    ZoneRules test = europeLondon();
    List<ZoneOffsetTransition> trans = test.getTransitions();

    ZoneOffsetTransition first = trans.get(0);
    assertEquals(first.getDateTimeBefore(), LocalDateTime.of(1847, 12, 1, 0, 0));
    assertEquals(first.getOffsetBefore(), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15));
    assertEquals(first.getOffsetAfter(), OFFSET_ZERO);

    ZoneOffsetTransition spring1916 = trans.get(1);
    assertEquals(spring1916.getDateTimeBefore(), LocalDateTime.of(1916, 5, 21, 2, 0));
    assertEquals(spring1916.getOffsetBefore(), OFFSET_ZERO);
    assertEquals(spring1916.getOffsetAfter(), OFFSET_PONE);

    ZoneOffsetTransition autumn1916 = trans.get(2);
    assertEquals(autumn1916.getDateTimeBefore(), LocalDateTime.of(1916, 10, 1, 3, 0));
    assertEquals(autumn1916.getOffsetBefore(), OFFSET_PONE);
    assertEquals(autumn1916.getOffsetAfter(), OFFSET_ZERO);

    ZoneOffsetTransition zot = null;
    Iterator<ZoneOffsetTransition> it = trans.iterator();
    while (it.hasNext()) {
        zot = it.next();
        if (zot.getDateTimeBefore().getYear() == 1990) {
            break;
        }
    }
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 3, 25, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1990, 10, 28, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 3, 31, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1991, 10, 27, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 3, 29, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1992, 10, 25, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 3, 28, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1993, 10, 24, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 3, 27, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1994, 10, 23, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 3, 26, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1995, 10, 22, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 3, 31, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1996, 10, 27, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 3, 30, 1, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_ZERO);
    zot = it.next();
    assertEquals(zot.getDateTimeBefore(), LocalDateTime.of(1997, 10, 26, 2, 0));
    assertEquals(zot.getOffsetBefore(), OFFSET_PONE);
    assertEquals(it.hasNext(), false);
}