本文整理匯總了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)));
}