java.time.ZonedDateTime.of() 方法
描述
java.time.ZonedDateTime.of(LocalDateTime date, ZoneId zone) 方法从日期时间和时区获取 ZonedDateTime 的实例。
声明
以下是 java.time.ZonedDateTime.of(LocalDateTime date, ZoneId zone) 方法的声明。
public static ZonedDateTime of(LocalDateTime date, ZoneId zone)
参数
date − 本地日期时间,不为空
zone − 时区,不为空
返回值
分区日期时间,不为空。
示例
下面的例子展示了 java.time.ZonedDateTime.of(LocalDateTime date, ZoneId zone) 方法的使用。
package com.tutorialspoint;
import java.time.LocalDateTime;
import java.time.ZonedDateTime;
import java.time.ZoneId;
public class ZonedDateTimeDemo {
public static void main(String[] args) {
ZonedDateTime date = ZonedDateTime.of(LocalDateTime.now(), ZoneId.systemDefault());
System.out.println(date);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
2017-03-28T13:57:45.878+05:30[Asia/Calcutta]

