Is there any way to convert ZoneId to ZoneOffset in java 8?

前端 未结 7 1238
礼貌的吻别
礼貌的吻别 2020-12-13 05:26

I have an epoch second and a zoneId,by method1.It can be convert to LocalDateTime with system default zoneId,but I don\'t find the way to convert epoch second to LocalDateTi

7条回答
  •  忘掉有多难
    2020-12-13 06:11

    There is no one-to-one mapping. A ZoneId defines a geographic extent in which a set of different ZoneOffsets is used over time. If the timezone uses daylight saving time, its ZoneOffset will be different between summer and winter.

    Furthermore, the daylight saving time rules may have changed over time, so the ZoneOffset could be different for e.g. 13/10/2015 compared to 13/10/1980.

    So you can only find the ZoneOffset for a ZoneId on a particular Instant.

    See also https://en.wikipedia.org/wiki/Tz_database

提交回复
热议问题