本文整理汇总了Java中java.time.ZoneOffset.adjustInto方法的典型用法代码示例。如果您正苦于以下问题:Java ZoneOffset.adjustInto方法的具体用法?Java ZoneOffset.adjustInto怎么用?Java ZoneOffset.adjustInto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZoneOffset
的用法示例。
在下文中一共展示了ZoneOffset.adjustInto方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test_adjustInto_ZonedDateTime
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test
public void test_adjustInto_ZonedDateTime() {
ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
for (String zoneId : ZoneId.getAvailableZoneIds()) {
//Do not change offset of ZonedDateTime after adjustInto()
ZonedDateTime zonedDateTime_target = ZonedDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneId.of(zoneId));
ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());
OffsetDateTime offsetDateTime_target = zonedDateTime_target.toOffsetDateTime();
OffsetDateTime offsetDateTime_result = (OffsetDateTime)(base.adjustInto(offsetDateTime_target));
assertEquals(base, offsetDateTime_result.getOffset());
}
}
示例2: test_adjustInto_OffsetDateTime
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test
public void test_adjustInto_OffsetDateTime() {
ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
for (int i=-18; i<=18; i++) {
OffsetDateTime offsetDateTime_target = OffsetDateTime.of(LocalDate.of(1909, 2, 2), LocalTime.of(10, 10, 10), ZoneOffset.ofHours(i));
OffsetDateTime offsetDateTime_result = (OffsetDateTime)base.adjustInto(offsetDateTime_target);
assertEquals(base, offsetDateTime_result.getOffset());
//Do not change offset of ZonedDateTime after adjustInto()
ZonedDateTime zonedDateTime_target = offsetDateTime_target.toZonedDateTime();
ZonedDateTime zonedDateTime_result = (ZonedDateTime)(base.adjustInto(zonedDateTime_target));
assertEquals(zonedDateTime_target.getOffset(), zonedDateTime_result.getOffset());
}
}
示例3: test_adjustInto_dateOnly
import java.time.ZoneOffset; //导入方法依赖的package包/类
@Test(expectedExceptions=DateTimeException.class)
public void test_adjustInto_dateOnly() {
ZoneOffset base = ZoneOffset.ofHoursMinutesSeconds(1, 1, 1);
base.adjustInto((LocalDate.of(1909, 2, 2)));
}