当前位置: 首页>>代码示例>>Java>>正文


Java ZonedDateTime.withZoneSameInstant方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:EHRI,项目名称:rs-aggregator,代码行数:13,代码来源:ZonedDateTimeUtil.java

示例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();
}
 
开发者ID:EHRI,项目名称:rs-aggregator,代码行数:8,代码来源:ZonedDateTimeUtil.java

示例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());
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:12,代码来源:DatumLiteral.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:8,代码来源:TCKZonedDateTime.java

示例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);
}
 
开发者ID:thebrightspark,项目名称:MDC-Discord-Bot,代码行数:6,代码来源:CommandTimeZone.java

示例6: advanceTo

import java.time.ZonedDateTime; //导入方法依赖的package包/类
@Override
public void advanceTo(ZonedDateTime d) {
    ZonedDateTime dUtc = d.withZoneSameInstant(ZoneId.of("UTC"));
    it.advanceTo(zonedDateTimeToDateValue(dUtc));
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:6,代码来源:ZonedDateTimeIteratorFactory.java

示例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;
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:7,代码来源:DateUtil.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:7,代码来源:TCKZonedDateTime.java

示例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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:6,代码来源:TCKZonedDateTime.java

示例10: nowUTC

import java.time.ZonedDateTime; //导入方法依赖的package包/类
public static String nowUTC() {
    ZonedDateTime localNow = ZonedDateTime.now();
    ZonedDateTime utcNow = localNow.withZoneSameInstant(utc);
    return utcNow.format(comparableFormatter);
}
 
开发者ID:schibsted,项目名称:strongbox,代码行数:6,代码来源:FormattedTimestamp.java

示例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());
}
 
开发者ID:gentoku,项目名称:pinnacle-api-client,代码行数:14,代码来源:Parameter.java

示例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));
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:9,代码来源:DatumTijdElement.java


注:本文中的java.time.ZonedDateTime.withZoneSameInstant方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。