Android Timezone.getDefault() gives Asia/Calcutta and not Asia/Kolkata

和自甴很熟 提交于 2020-01-16 01:56:12

问题


I am using the Android TimeZone functionality and my app is communicating with a server that expects Asia/Kolkata from devices in India. However, when getting the TimeZone.getDefault().getDisplayName(), I get Asia/Calcutta and not Kolkata. Knowing that when printing the values in TimeZone.getAvailableIDs(), it shows both, Calcutta and Kolkata. Any ideas?


回答1:


Both should be valid. The zone used to be called Asia/Calcutta and was renamed to Asia/Kolkata, but there is still an alias in the tzdb that points the old name to the new one. See here.

If the server doesn't allow the new name, then they need to update their tz files from here, or in whatever implementation they might be using.

If you can't do that, you can always catch this case and replace the string yourself. They are equivalent zones.



来源:https://stackoverflow.com/questions/16590376/android-timezone-getdefault-gives-asia-calcutta-and-not-asia-kolkata

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