Saturday, August 30, 2025
HomeLanguagesJavaTimeZone getAvailableIDs(int val_offset) Method in Java with Examples

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 where the time zone for that ID has a specified value. Below programs illustrate the working of getAvailableIDs() Method of TimeZone: Example 1: 

Java




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


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: 

Java




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


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)

RELATED ARTICLES

Most Popular

Dominic
32250 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6617 POSTS0 COMMENTS
Nicole Veronica
11792 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11840 POSTS0 COMMENTS
Shaida Kate Naidoo
6733 POSTS0 COMMENTS
Ted Musemwa
7014 POSTS0 COMMENTS
Thapelo Manthata
6689 POSTS0 COMMENTS
Umr Jansen
6704 POSTS0 COMMENTS