Java Utility Library

Java TimeZone - getAvailableIDs() Method



The java.util.TimeZone.getAvailableIDs() method is used to get the available IDs according to the given time zone offset in milliseconds.

Syntax

public static String[] getAvailableIDs(int rawOffset)

Parameters

rawOffset Specify the given time zone GMT offset in milliseconds.

Return Value

Returns an array of IDs, where the time zone for that ID has the specified GMT offset. For example, "America/Phoenix" and "America/Denver" both have GMT-07:00, but differ in daylight saving behavior.

Exception

NA

Example:

In the example below, the java.util.TimeZone.getAvailableIDs() method is used to get all the available IDs according to the rawOffset.

import java.util.*;

public class MyClass {
  public static void main(String[] args) {
    //getting the available IDs for offset
    String[] availID = TimeZone.getAvailableIDs(3600000);

    //printing the available IDs
    for(String s: availID)
      System.out.println(s);
  }
}

The output of the above code will be:

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

❮ Java.util - TimeZone