當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。