How do I get timezone ids by their milliseconds offset?

package org.kodejava.example.util;

import java.util.TimeZone;

public class TimezoneByOffset {
    public static void main(String[] args) {
        //
        // Gets the available IDs according to the given time zone
        // offset in milliseconds.
        //
        int offset = 8 * 60 * 60 * 1000;
        String[] timezones = TimeZone.getAvailableIDs(offset);

        System.out.println("List of available IDs for GMT:+08:00");
        System.out.println("====================================");
        for (String id : timezones) {
            System.out.println(id);
        }
    }
}

Here are the timezone ids in the GMT+8 offset:

List of available IDs for GMT:+08:00
====================================
Asia/Brunei
Asia/Choibalsan
Asia/Chongqing
Asia/Chungking
Asia/Harbin
Asia/Hong_Kong
Asia/Irkutsk
Asia/Kashgar
Asia/Kuala_Lumpur
Asia/Kuching
Asia/Macao
Asia/Macau
Asia/Makassar
Asia/Manila
Asia/Shanghai
Asia/Singapore
Asia/Taipei
Asia/Ujung_Pandang
Asia/Ulaanbaatar
Asia/Ulan_Bator
Asia/Urumqi
Australia/Perth
Australia/West
CTT
Etc/GMT-8
Hongkong
PRC
Singapore
Wayan Saryada

Wayan Saryada

A programmer, runner, recreational diver, currently living in the island of Bali, Indonesia. Mostly programming in Java, creating web based application with Spring Framework, JPA, etc. If you need help on Java programming you can hire me on Fiverr.
Wayan Saryada

Leave a Reply