java.time.ZonedDateTime.of(LocalDate date,LocalTime time,ZoneId zone)方法从日期,时间和时区获取ZonedDateTime的实例。
声明
以下是java.time.ZonedDateTime.of(LocalDate date,LocalTime time,ZoneId zone)方法的声明。
public static ZonedDateTime of(LocalDate date, LocalTime time, ZoneId zone)
参数
- date- 本地日期,不为- null
- time- 当地时间,不为- null
- zone- 时区,不为- null
返回值
分区日期时间,不为null。
示例
以下示例显示了java.time.ZonedDateTime.of(LocalDate date,LocalTime time,ZoneId zone)方法的用法。
package com.zaixian;
import java.time.LocalDate;
import java.time.ZonedDateTime;
import java.time.LocalTime;
import java.time.ZoneId;
public class ZonedDateTimeDemo {
   public static void main(String[] args) {
      LocalDate localDate = LocalDate.parse("2017-02-03");
      LocalTime localTime = LocalTime.parse("12:30:30");
      ZonedDateTime date = ZonedDateTime.of(localDate, localTime, ZoneId.systemDefault());
      System.out.println(date);  
   }
}
编译并运行上面的程序,这将产生以下结果 -
2017-02-03T12:30:30+05:30[Asia/Calcutta]
						上一篇:
								java.time.ZonedDateTime类
												下一篇:
								java.time.ZoneId类
												
						
						
					
					
					