java.time.ZonedDateTime.from(TemporalAccessor temporal)
方法從時態對象獲取ZonedDateTime
的實例。
聲明
以下是java.time.ZonedDateTime.from(TemporalAccessor temporal)
方法的聲明。
public static ZonedDateTime from(TemporalAccessor temporal)
參數
temporal
- 要轉換的時間對象,而不是null
。
返回值
本地日期,不為null
。
例外
DateTimeException
- 如果無法轉換為ZonedDateTime
。
示例
以下示例顯示了java.time.ZonedDateTime.from(TemporalAccessor temporal)
方法的用法。
package com.zaixian;
import java.time.ZonedDateTime;
public class ZonedDateTimeDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.from(ZonedDateTime.now());
System.out.println(date);
}
}
編譯並運行上面的程式,這將產生以下結果 -
2017-03-28T12:25:38.492+05:30[Asia/Calcutta]
上一篇:
java.time.ZonedDateTime類
下一篇:
java.time.ZoneId類