Android Timezone.getDefault()提供Asia/Calcutta,而不提供Asia/Kolkata [英] Android Timezone.getDefault() gives Asia/Calcutta and not Asia/Kolkata
问题描述
我正在使用Android TimeZone功能,并且我的应用正在与一台服务器通信,该服务器希望印度的设备来自亚洲/加尔各答.但是,当获取 TimeZone.getDefault().getDisplayName()
时,我得到的是Asia/Calcutta,而不是加尔各答.知道在打印 TimeZone.getAvailableIDs()
中的值时,它同时显示了加尔各答和加尔各答.有什么想法吗?
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?
推荐答案
两者均应有效.该区域以前称为 Asia/Calcutta
,并重命名为 Asia/Kolkata
,但是tzdb中仍然有一个别名,将旧名称指向新名称.请参见此处.
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.
这篇关于Android Timezone.getDefault()提供Asia/Calcutta,而不提供Asia/Kolkata的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!