package org.nhooo.example.util; import java.util.TimeZone; public class TimeZoneByOffset { public static void main(String[] args) { // 根据给定的时区获取可用的ID // 偏移量(以毫秒为单位)。 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); } } }
以下是GMT + 8偏移量中的时区ID:
List of available IDs for GMT:+08:00 ==================================== Asia/Brunei Asia/Choibalsan Asia/Chongqing Asia/Chungking Asia/Harbin Asia/Hong_Kong Asia/Irkutsk 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 Australia/Perth Australia/West CTT Etc/GMT-8 Hongkong PRC Singapore