TimeZone getAvailableIDs(int val_offset) Method in Java with Examples

The getAvailableIDs(int val_offset) method of TimeZone class in Java is used to get the list of all the supported and available IDs in the TimeZone class according to a provided offset value.

Syntax:

public static String[] getAvailableIDs(int val_offset)

Parameters: The method takes one parameter val_offset of Integer type which refers to the time zone offset value..

Return Value: The method returns an array of all the available IDs wherer the time zone for that ID has a specified value.

Below programs illustrate the working of getAvailableIDs() Method of TimeZone:

Example 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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]);
    }
}

chevron_right


Output:

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

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

// 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]);
    }
}

chevron_right


Output:

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

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



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.