Java.util.TimeZone 类

java.util.TimeZone.getAvailableIDs() 方法用于根据给定的时区偏移量获取可用的 ID以毫秒为单位。

语法

public static String[] getAvailableIDs(int rawOffset)

参数

rawOffset 指定给定时区 GMT 偏移量(以毫秒为单位)。

返回值

返回 ID 数组,其中该 ID 的时区具有指定的 GMT 偏移量。例如,"America/Phoenix"和"America/Denver"的时间均为 GMT-07:00,但夏令时行为不同。

例外

示例:

下面的示例中,使用java.util.TimeZone.getAvailableIDs()方法根据rawOffset。

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //获取偏移量的可用ID
    String[] availID = TimeZone.getAvailableIDs(3600000);

    //打印可用的ID
    for(String s: availID)
      System.out.println(s);
  }
}

上述代码的输出将是:

Africa/Algiers
Africa/Bangui
Africa/Brazzaville
Africa/Ceuta
Africa/Douala
Africa/Kinshasa
Africa/Lagos
Africa/Libreville
Africa/Luanda
Africa/Malabo
Africa/Ndjamena
Africa/Niamey
Africa/Porto-Novo
Africa/Tunis
Africa/Windhoek
Arctic/Longyearbyen
Atlantic/Jan_Mayen
CET
ECT
Etc/GMT-1
Europe/Amsterdam
Europe/Andorra
Europe/Belgrade
Europe/Berlin
Europe/Bratislava
Europe/Brussels
Europe/Budapest
Europe/Busingen
Europe/Copenhagen
Europe/Gibraltar
Europe/Ljubljana
Europe/Luxembourg
Europe/Madrid
Europe/Malta
Europe/Monaco
Europe/Oslo
Europe/Paris
Europe/Podgorica
Europe/Prague
Europe/Rome
Europe/San_Marino
Europe/Sarajevo
Europe/Skopje
Europe/Stockholm
Europe/Tirane
Europe/Vaduz
Europe/Vatican
Europe/Vienna
Europe/Warsaw
Europe/Zagreb
Europe/Zurich
MET
Poland