本文整理汇总了Java中java.time.zone.ZoneRules.getTransitions方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneRules.getTransitions方法的具体用法?Java ZoneRules.getTransitions怎么用?Java ZoneRules.getTransitions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.zone.ZoneRules
的用法示例。
在下文中一共展示了ZoneRules.getTransitions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_London_nextTransition_rulesBased
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}
}
示例2: test_London_previousTransition_historic
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}
}
示例3: test_London_nextTransition_historic
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}
}
示例4: test_London_previousTransition_rulesBased
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}
}
示例5: test_Kathmandu_nextTransition_historic
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}
}
示例6: test_Kathmandu_nextTransition_noRules
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}
示例7: test_Apia_nextTransition_historic
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}
}
示例8: test_London_getTransitions
import java.time.zone.ZoneRules; //导入方法依赖的package包/类
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);
}