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)
相關用法
- Java TimeZone observesDaylightTime()用法及代碼示例
- Java TimeZone setID()用法及代碼示例
- Java TimeZone inDaylightTime()用法及代碼示例
- Java TimeZone getID()用法及代碼示例
- Java TimeZone setRawOffset()用法及代碼示例
- Java TimeZone getDefault()用法及代碼示例
- Java TimeZone getTimeZone()用法及代碼示例
- Java TimeZone getAvailableIDs()用法及代碼示例
- Java TimeZone getRawOffset()用法及代碼示例
- Java TimeZone setDefault()用法及代碼示例
- Java TimeZone clone()用法及代碼示例
- Java TimeZone getDisplayName()用法及代碼示例
- Java TimeZone hasSameRules()用法及代碼示例
- Java TimeZone getDSTSavings()用法及代碼示例
- Java TimeZone getOffset()用法及代碼示例
注:本文由純淨天空篩選整理自Chinmoy Lenka大神的英文原創作品 TimeZone getAvailableIDs(int val_offset) Method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。