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

后端 未结 3 1417
迷失自我
迷失自我 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:20

    Of course it's doable... but you'll have to write some code.

    You'll have to front your time zone selection with code which filters the list of timezones. You'd populate that filter with a map of locales to the set of timezones for the locale.

    However, as David noted, you will face the issue of people whose Locale is not their work location or timezone, so be prepared to deal with this in a two-tiered approach, or to pick up "virtual locale" from somewhere.

提交回复
热议问题