Get the IDs according to the given time zone offset in Java


In order to get the IDs according to the given time zone offset in Java, we use the getAvailableIDs(int rawOffset) method. The java.util.TimeZone.getAvailableIDs(int rawOffset) method returns the available IDs according to the given time zone offset in the arguments.

Declaration − The java.util.TimeZone.getAvailableIDs(int rawOffset) method is declared as follows −

public static String[] getAvailableIDs(int rawOffset)

where rawOffset is the given time zone GMT offset.

Let us see a Java program which gets the IDs according to the given time zone offset −

Example

 Live Demo

import java.util.*;
public class Example {
   public static void main(String args[]) {
      // getting available supported ids for given offset
      String[] id = TimeZone.getAvailableIDs(36000000);
      // printing available ids for offset
      System.out.println("The available IDs are as follows:");
      for (int i = 0; i< id.length; i++) {
         System.out.println(id[i]);
      }
   }
}

Output

The available IDs are as follows:
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

Updated on: 26-Jun-2020

158 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements