是否可以通过Java中的Locale列出可用的TimeZones? [英] Is it possible to list available TimeZones by Locale in Java?

查看:116
本文介绍了是否可以通过Java中的Locale列出可用的TimeZones?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要生成要为用户显示的时区列表。我们想根据用户的Locale缩小列表范围。

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.

如果用户的语言环境为en_US,他可能并不关心列表中的Asia / Ashkhabad。

If the user has a locale of 'en_US', he probably doesn't care to see 'Asia/Ashkhabad' in the list.

这可行吗?

推荐答案

不,你不能。您可以使用TimeZone.getAvailableIDs(int rawoffset)来缩小结果范围,但是您需要保留Locale-> raw offset的映射。

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.

此外,如果发生了什么您的用户是位于印度的美国人吗?你不想为他显示Banglor时区吗?

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

这篇关于是否可以通过Java中的Locale列出可用的TimeZones?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆