Skip to content
Related Articles

Related Articles

Improve Article

TimeZone getAvailableIDs(int val_offset) Method in Java with Examples

  • Last Updated : 31 Jan, 2019

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:




// 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 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)

Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more,  please refer Complete Interview Preparation Course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :