本文整理汇总了Java中java.time.ZonedDateTime.withZoneSameInstant方法的典型用法代码示例。如果您正苦于以下问题:Java ZonedDateTime.withZoneSameInstant方法的具体用法?Java ZonedDateTime.withZoneSameInstant怎么用?Java ZonedDateTime.withZoneSameInstant使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.time.ZonedDateTime
的用法示例。
在下文中一共展示了ZonedDateTime.withZoneSameInstant方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromXmlString
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime fromXmlString(String value) {
if (value == null) {
return null;
}
if (value.matches(".*([Z]|[+-][0-9]{1,2}:[0-9]{1,2})$")) {
return ZonedDateTime.parse(value).withZoneSameInstant(ZoneOffset.UTC);
} else {
LocalDateTime local = LocalDateTime.parse(value, localFormat);
ZonedDateTime localZ = ZonedDateTime.of(local, getZoneId());
return localZ.withZoneSameInstant(ZoneOffset.UTC);
}
}
示例2: toXmlString
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static String toXmlString(ZonedDateTime value) {
if (value == null) {
return null;
}
ZonedDateTime utc = value.withZoneSameInstant(ZoneOffset.UTC);
return utc.toString();
}
示例3: DatumLiteral
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param dt DateTime-waarde voor datum literal.
*/
public DatumLiteral(final ZonedDateTime dt) {
final ZonedDateTime inNederland = dt.withZoneSameInstant(DatumUtil.NL_ZONE_ID);
this.jaar = Datumdeel.valueOf(inNederland.getYear());
this.maand = Datumdeel.valueOf(inNederland.getMonthValue());
this.dag = Datumdeel.valueOf(inNederland.getDayOfMonth());
}
示例4: test_withZoneSameInstant
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void test_withZoneSameInstant() {
ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
ZonedDateTime test = base.withZoneSameInstant(ZONE_0200);
ZonedDateTime expected = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500.plusHours(1), ZONE_0200);
assertEquals(test, expected);
}
示例5: convertTime
import java.time.ZonedDateTime; //导入方法依赖的package包/类
private ZonedDateTime convertTime(LocalDateTime time, ZoneId zoneFrom, ZoneId zoneTo)
{
ZonedDateTime timeFrom = ZonedDateTime.of(time, zoneFrom);
return timeFrom.withZoneSameInstant(zoneTo);
}
示例6: advanceTo
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public void advanceTo(ZonedDateTime d) {
ZonedDateTime dUtc = d.withZoneSameInstant(ZoneId.of("UTC"));
it.advanceTo(zonedDateTimeToDateValue(dUtc));
}
示例7: toUtc
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static ZonedDateTime toUtc(ZonedDateTime zonedDateTime) {
if (zonedDateTime.getZone() != ZONE_UTC) {
return zonedDateTime.withZoneSameInstant(DateUtil.ZONE_UTC);
}
return zonedDateTime;
}
示例8: test_withZoneSameInstant_noChange
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test
public void test_withZoneSameInstant_noChange() {
ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
ZonedDateTime test = base.withZoneSameInstant(ZONE_0100);
assertEquals(test, base);
}
示例9: test_withZoneSameInstant_null
import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Test(expectedExceptions=NullPointerException.class)
public void test_withZoneSameInstant_null() {
ZonedDateTime base = ZonedDateTime.of(TEST_LOCAL_2008_06_30_11_30_59_500, ZONE_0100);
base.withZoneSameInstant(null);
}
示例10: nowUTC
import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static String nowUTC() {
ZonedDateTime localNow = ZonedDateTime.now();
ZonedDateTime utcNow = localNow.withZoneSameInstant(utc);
return utcNow.format(comparableFormatter);
}
示例11: toDate
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
* Alternate method. ZonedDateTime.toString returns like
* "2016-12-02T23:59:59Z[UTC]" but Pinnacle API doesn't accept last square
* brackets so needs to convert to LocalDateTime.
*
* @param fromDate
* @throws PinnacleException
*/
public void toDate(ZonedDateTime fromDate) throws PinnacleException {
if (fromDate == null) throw PinnacleException.parameterInvalid("Parameter cannot accept null.");
ZonedDateTime utc = fromDate.withZoneSameInstant(Constants.TIME_ZONE);
this.toDate(utc.toLocalDateTime());
}
示例12: DatumTijdElement
import java.time.ZonedDateTime; //导入方法依赖的package包/类
/**
* Maakt een nieuw DatumElement object.
*
* @param waarde de datum waarde, mag niet null zijn
*/
public DatumTijdElement(final ZonedDateTime waarde) {
super(waarde.withZoneSameInstant(DatumUtil.BRP_ZONE_ID));
}