Convert country-state code to time zone in Java

…衆ロ難τιáo~ 提交于 2021-02-04 16:28:26

问题


Having country-state code as input, is it possible to get the timezone using Java? For example us-tx -> (GMT-6)

Tried using this answer, however this method uses only the country code, without the state and the output is :

US/Alaska_US/Aleutian_US/Arizona_US/Central_US/East-Indiana_US/Eastern_US/Hawaii_US/Indiana-Starke_US/Michigan_US/Mountain_US/Pacific_US/Pacific-New_US/Samoa

回答1:


This isn't possible - in any language. Many US states have more than one time zone, depending on which part of the state you are referring to:

From Wikipedia:

You can clearly see on this map, many states where the time zone boundary does not follow the state boundary.



来源:https://stackoverflow.com/questions/65007075/convert-country-state-code-to-time-zone-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!