Open In App

TimeZone getAvailableIDs(int val_offset) Method in Java with Examples

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Share
Report issue
Report

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)



Last Updated : 25 Nov, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads