本文整理汇总了Java中java.time.ZonedDateTime.plusMonths方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.plusMonths方法的具体用法?Java ZonedDateTime.plusMonths怎么用?Java ZonedDateTime.plusMonths使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.plusMonths方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_Paris_getStandardOffset
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public void test_Paris_getStandardOffset() {
ZoneRules test = europeParis();
ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
while (zdt.getYear() < 2010) {
Instant instant = zdt.toInstant();
if (zdt.toLocalDate().isBefore(LocalDate.of(1911, 3, 11))) {
assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, 9, 21));
} else if (zdt.toLocalDate().isBefore(LocalDate.of(1940, 6, 14))) {
assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
} else if (zdt.toLocalDate().isBefore(LocalDate.of(1944, 8, 25))) {
assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
} else if (zdt.toLocalDate().isBefore(LocalDate.of(1945, 9, 16))) {
assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
} else {
assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
}
zdt = zdt.plusMonths(6);
}
}
示例2: test_plusMonths
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void test_plusMonths() {
LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
ZonedDateTime test = base.plusMonths(1);
assertEquals(test, ZonedDateTime.of(ldt.plusMonths(1), ZONE_0100));
}
示例3: test_plusMonths_zero
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void test_plusMonths_zero() {
LocalDateTime ldt = LocalDateTime.of(2008, 6, 30, 23, 30, 59, 0);
ZonedDateTime base = ZonedDateTime.of(ldt, ZONE_0100);
ZonedDateTime test = base.plusMonths(0);
assertEquals(test, base);
}
示例4: test_London_getStandardOffset
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public void test_London_getStandardOffset() {
ZoneRules test = europeLondon();
ZonedDateTime zdt = createZDT(1840, 1, 1, ZoneOffset.UTC);
while (zdt.getYear() < 2010) {
Instant instant = zdt.toInstant();
if (zdt.getYear() < 1848) {
assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHoursMinutesSeconds(0, -1, -15));
} else if (zdt.getYear() >= 1969 && zdt.getYear() < 1972) {
assertEquals(test.getStandardOffset(instant), OFFSET_PONE);
} else {
assertEquals(test.getStandardOffset(instant), OFFSET_ZERO);
}
zdt = zdt.plusMonths(6);
}
}
示例5: test_NewYork_getStandardOffset
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public void test_NewYork_getStandardOffset() {
ZoneRules test = americaNewYork();
ZonedDateTime dateTime = createZDT(1860, 1, 1, ZoneOffset.UTC);
while (dateTime.getYear() < 2010) {
Instant instant = dateTime.toInstant();
if (dateTime.toLocalDate().isBefore(LocalDate.of(1883, 11, 18))) {
assertEquals(test.getStandardOffset(instant), ZoneOffset.of("-04:56:02"));
} else {
assertEquals(test.getStandardOffset(instant), ZoneOffset.ofHours(-5));
}
dateTime = dateTime.plusMonths(6);
}
}