当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java TimeZone getAvailableIDs(int val_offset)用法及代码示例


Java中的TimeZone类的getAvailableIDs(int val_offset)方法用于根据提供的偏移值获取TimeZone类中所有受支持的ID和可用ID的列表。

用法:

public static String[] getAvailableIDs(int val_offset)



参数:该方法采用一个整数类型的参数val_offset,它引用时区偏移值。

返回值:该方法返回所有可用ID的数组,其中该ID的时区具有指定值。

下面的程序演示了TimeZone的getAvailableIDs()方法的用法:

范例1:

// Java code to illustrate 
// getAvailableIDs() method 
  
import java.util.*; 
  
public class TimeZone_Demo { 
    public static void main(String args[]) 
    { 
  
        // Storing all the available Ids 
        String[] Id_array 
            = TimeZone.getAvailableIDs(7200000); 
  
        // Displaying all the available Ids 
        System.out.println("All the available"
                           + " Ids are:"); 
  
        for (int count = 0; 
             count < Id_array.length; 
             count++) 
            System.out.println(Id_array[count]); 
    } 
}
输出:
All the available Ids are:
ART
Africa/Blantyre
Africa/Bujumbura
Africa/Cairo
Africa/Gaborone
Africa/Harare
Africa/Johannesburg
Africa/Khartoum
Africa/Kigali
Africa/Lubumbashi
Africa/Lusaka
Africa/Maputo
Africa/Maseru
Africa/Mbabane
Africa/Tripoli
Africa/Windhoek
Asia/Amman
Asia/Beirut
Asia/Damascus
Asia/Famagusta
Asia/Gaza
Asia/Hebron
Asia/Jerusalem
Asia/Nicosia
Asia/Tel_Aviv
CAT
EET
Egypt
Etc/GMT-2
Europe/Athens
Europe/Bucharest
Europe/Chisinau
Europe/Helsinki
Europe/Kaliningrad
Europe/Kiev
Europe/Mariehamn
Europe/Nicosia
Europe/Riga
Europe/Sofia
Europe/Tallinn
Europe/Tiraspol
Europe/Uzhgorod
Europe/Vilnius
Europe/Zaporozhye
Israel
Libya

范例2:

// Java code to illustrate 
// getAvailableIDs() method 
  
import java.util.*; 
  
public class TimeZone_Demo { 
    public static void main(String args[]) 
    { 
  
        // Storing all the available Ids 
        String[] Id_array 
            = TimeZone.getAvailableIDs(36000000); 
  
        // Displaying all the available Ids 
        System.out.println("All the available"
                           + " Ids are:"); 
  
        for (int count = 0; 
             count < Id_array.length; 
             count++) 
            System.out.println(Id_array[count]); 
    } 
}
输出:
All the available Ids are:
AET
Antarctica/DumontDUrville
Asia/Ust-Nera
Asia/Vladivostok
Australia/ACT
Australia/Brisbane
Australia/Canberra
Australia/Currie
Australia/Hobart
Australia/Lindeman
Australia/Melbourne
Australia/NSW
Australia/Queensland
Australia/Sydney
Australia/Tasmania
Australia/Victoria
Etc/GMT-10
Pacific/Chuuk
Pacific/Guam
Pacific/Port_Moresby
Pacific/Saipan
Pacific/Truk
Pacific/Yap

参考: https://docs.oracle.com/javase/7/docs/api/java/util/TimeZone.html#getAvailableIDs(int)



相关用法


注:本文由纯净天空筛选整理自Chinmoy Lenka大神的英文原创作品 TimeZone getAvailableIDs(int val_offset) Method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。