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



說明

**Java.time.ZonedDateTime.toOffsetDateTime()**方法將此日期時間轉換為 OffsetDateTime。

宣告

以下是 **Java.time.ZonedDateTime.toOffsetDateTime()** 方法的宣告。

public OffsetDateTime toOffsetDateTime()

返回值

表示相同本地日期時間和偏移的偏移日期時間,非空。

示例

以下示例演示了 Java.time.ZonedDateTime.toOffsetDateTime() 方法的用法。

package com.tutorialspoint;

import java.time.ZonedDateTime;

public class ZonedDateTimeDemo {
   public static void main(String[] args) {
 
      ZonedDateTime date = ZonedDateTime.now();
      System.out.println(date.toOffsetDateTime());  
   }
}

讓我們編譯並執行上面的程式,這將產生以下結果 –

2017-03-28T15:45:22.794+05:30
廣告