java.time.ZonedDateTime.withEarlierOffsetAtOverlap() 方法示例



描述

java.time.ZonedDateTime.withEarlierOffsetAtOverlap() 方法將此日期時間複製並修改時區偏移為在本地時間線重疊時兩個有效的偏移中較早的一個。

宣告

以下是 java.time.ZonedDateTime.withEarlierOffsetAtOverlap() 方法的宣告。

public ZonedDateTime withEarlierOffsetAtOverlap()

返回值

基於此日期時間且帶有較早偏移的 ZonedDateTime,非空。

示例

以下示例顯示了 java.time.ZonedDateTime.withEarlierOffsetAtOverlap() 方法的用法。

package com.tutorialspoint;

import java.time.ZonedDateTime;

public class ZonedDateTimeDemo {
   public static void main(String[] args) {
      
      ZonedDateTime date = ZonedDateTime.parse("2017-03-28T12:25:38.492+05:30[Asia/Calcutta]");
      ZonedDateTime result = date.withEarlierOffsetAtOverlap();
      System.out.println(result);  
   }
}

讓我們編譯並執行以上程式,它將產生以下結果 −

2017-03-28T12:25:38.492+05:30[Asia/Calcutta]
廣告
© . All rights reserved.