Is it possible to list available TimeZones by Locale in Java?

后端 未结 3 1455
迷失自我
迷失自我 2021-01-20 01:33

I need to generate a list of timezones to display for a user. We\'d like to narrow the list down depending on the user\'s Locale.

If the user has a locale of \'en

3条回答
  •  半阙折子戏
    2021-01-20 02:11

    No you can't. You can use TimeZone.getAvailableIDs(int rawoffset) to narrow the results, but then you need to keep a map of Locale->raw offsets.

    Also, what happens if your user is an American located in India? Don't you want to display the Asia/Kolkata time zone for him?

提交回复
热议问题