java.time.OffsetDateTime.toZonedDateTime()
方法使用offset
作為區域ID將此日期時間轉換為ZonedDateTime
。
聲明
以下是java.time.OffsetDateTime.toZonedDateTime()
方法的聲明。
public ZonedDateTime toZonedDateTime()
返回值
表示時間和偏移量的OffsetTime
,不為null
。
示例
以下示例顯示了java.time.OffsetDateTime.toZonedDateTime()
方法的用法。
package com.zaixian;
import java.time.OffsetDateTime;
public class OffsetDateTimeDemo {
public static void main(String[] args) {
OffsetDateTime date = OffsetDateTime.now();
System.out.println(date.toZonedDateTime());
}
}
編譯並運行上面的程式,這將產生以下結果 -
2017-03-21T14:35:55.111+05:30