如何从java中获取时区偏移量的时区? [英] How to get timezone from timezone offset in java?
本文介绍了如何从java中获取时区偏移量的时区?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道如何相反。这是一个时区,我可以通过以下代码片段获得时区偏移:
I know how to get the opposite. That is given a timezone I can get the timezone offset by the following code snippet:
TimeZone tz = TimeZone.getDefault();
System.out.println(tz.getOffset(System.currentTimeMillis()));
我想知道如何从时区偏移中获取时区名称。
I want to know how to get the timezone name from timezone offset.
给定,
时区偏移量= 21600000
(以毫秒为单位; +6.00偏移量)
timezone offset = 21600000
(in milliseconds; +6.00 offset)
我想得到以下任何可能的时区名称的结果:
I want to get result any of the following possible timezone names:
(GMT+6:00) Antarctica/Vostok
(GMT+6:00) Asia/Almaty
(GMT+6:00) Asia/Bishkek
(GMT+6:00) Asia/Dacca
(GMT+6:00) Asia/Dhaka
(GMT+6:00) Asia/Qyzylorda
(GMT+6:00) Asia/Thimbu
(GMT+6:00) Asia/Thimphu
(GMT+6:00) Asia/Yekaterinburg
(GMT+6:00) BST
(GMT+6:00) Etc/GMT-6
(GMT+6:00) Indian/Chagos
推荐答案
使用TimeZone类的getAvailableIDs()
Use getAvailableIDs() of TimeZone class
import java.util.*;
class hello
{
public static void main (String[] args) throws java.lang.Exception
{
TimeZone tz=TimeZone.getDefault();
String a[]=tz.getAvailableIDs(21600000);
for(int i=0;i<a.length;i++)
System.out.println(a[i]);
}
}
这篇关于如何从java中获取时区偏移量的时区?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文