我不明白这一点-根据定义,LocalDateTime在我的默认时区中-对吗?那么,为什么我需要提供一个从LocalDateTime转换为ZonedDateTime的区域?
答案 0 :(得分:1)
A date-time without a time-zone in the ISO-8601 calendar system, such as 2007-12-03T10:15:30.
因为它的命名不是特别好。只是一个没有时区的DateTime和一个“时钟”时间,如下所示:
This class does not store or represent a time-zone. Instead, it is a description of the date, as used for birthdays, combined with the local time as seen on a wall clock. It cannot represent an instant on the time-line without additional information such as an offset or time-zone.
这样,要转换为ZonedDateTime,您需要提供上下文。
来源:https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html