
- java.time 包類
- java.time - 首頁
- java.time - 時鐘
- java.time - 持續時間
- java.time - 瞬間
- java.time - 本地日期
- java.time - 本地日期時間
- java.time - 本地時間
- java.time - 月日
- java.time - 偏移日期時間
- java.time - 偏移時間
- java.time - 週期
- java.time - 年
- java.time - 年月
- java.time - 區域日期時間
- java.time - 區域 ID
- java.time - 區域偏移量
- java.time 包列舉
- java.time - 月
- java.time 有用資源
- java.time - 討論
java.time.ZonedDateTime.ofStrict() 方法示例
描述
java.time.ZonedDateTime.ofStrict(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone) 方法嚴格驗證本地日期時間、偏移量和區域 ID 組合,獲取 ZonedDateTime 的例項。
宣告
以下是 java.time.ZonedDateTime.ofStrict(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone) 方法的宣告。
public static ZonedDateTime ofStrict(LocalDateTime localDateTime, ZoneOffset offset, ZoneId zone)
```java
引數
localDateTime − 非空的本地日期時間。
offset − 非空的區域偏移量。
zone − 非空的時區。
返回值
非空的區域日期時間。
示例
package com.tutorialspoint; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.ZoneId; public class ZonedDateTimeDemo { public static void main(String[] args) { ZonedDateTime date = ZonedDateTime.ofStrict(LocalDateTime.now(), ZoneOffset.UTC, ZoneId.of("Z")); System.out.println(date); } }
即時演示
2017-03-28T14:12:19.482Z
列印頁面
廣告