gpt4 book ai didi

java - 如何获取 Java 8 中所有时区 ID 的列表?

转载 作者:行者123 更新时间:2023-12-02 05:23:45 26 4
gpt4 key购买 nike

java.time 包中,我没有看到获取可用时区 ID 列表的函数。我可以调用 java.util.TimeZone 库中的 getAvailableIDs() 。但是,我想改用 Java 8。

有办法做到这一点吗?

最佳答案

ZoneId.getAvailableZoneIds()

ZoneId 存在于 java.time 包。

ZoneId.getAvailableZoneIds() Set<String>

This set includes the string form of all available region-based IDs. Offset-based zone IDs are not included in the returned set. The ID can be passed to of(String) to create a ZoneId.

The set of zone IDs can increase over time, although in a typical application the set of IDs is fixed. Each call to this method is thread-safe.

关于java - 如何获取 Java 8 中所有时区 ID 的列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43145796/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com