static ZonedDateTime of(LocalDateTime date, ZoneId zone)
描述 (Description)
java.time.ZonedDateTime.of(LocalDateTime date, ZoneId zone)方法从日期时间和时区获取ZonedDateTime的实例。
声明 (Declaration)
以下是java.time.ZonedDateTime.of(LocalDateTime date, ZoneId zone)方法的声明。
public static ZonedDateTime of(LocalDateTime date, ZoneId zone)
参数 (Parameters)
date - 本地日期时间,不为null
zone - 时区,不为null
返回值 (Return Value)
分区日期时间,不为空。
例子 (Example)
以下示例显示了java.time.ZonedDateTime.of(LocalDateTime date,ZoneId zone)方法的用法。
package com.iowiki;
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]