【发布时间】:2020-02-25 03:21:02
【问题描述】:
我想在 GMT 中获取 LocalDateTime,所以用 ZonedDateTime 包装它。
但gmtZoneTime 以以下格式返回:2019-10-29T00:00Z[GMT] 而我需要它是:2019-10-29T00:00:00.000+0000
我应该如何正确地将localDateTime 转换为 GMT ZonedDateTime?
val currentDate:LocalDate = java.time.LocalDate.now
val localDateTime: LocalDateTime = currentDate.atStartOfDay
val gmtZoneTime: ZonedDateTime = localDateTime.atZone(ZoneId.systemDefault()).withZoneSameInstant(ZoneId.of("GMT"))
【问题讨论】: