【发布时间】:2023-01-18 20:01:56
【问题描述】:
我想验证我对 JSR310 类用例的理解是否正确,在带有类的图表下方,以及我如何看待它们:
Database (UTC)
||
\/
OffsetDateTime (used in persistence or transmission, databases and XML)
||
\/
Instant (used in business logic, for date time calculations)
||
\/
ZonedDateTime <-- ZoneId (used in presentation layer, requiring the client zoneId)
||
\/
LocalDateTime (used in presentation layer, obtained from ZonedDateTime)
||
\/
Front-end
我的不确定性与 ZonedDateTime 和 LocalDateTime 有关,因为据我所知两者都适用于表示层,尽管 LocalDatetime 没有时区或偏移量。
在 ZonedDateTime 处理了所有 DST 转换和异常之后,我应该发送到前端的 LocalDateTime 是什么?
我是否不将 ZonedDateTime 发送到前端,因为它有时区等额外信息?
提前致谢
【问题讨论】: