Java中如何获得所有可用时区?
package org.nhooo.example.util; import java.util.TimeZone; public class TimezonesExample { public static void main(String[] args) { String[] availableTimezones = TimeZone.getAvailableIDs(); for (String timezone : availableTimezones) { System.out.println("Timezone ID = " + timezone); } } }
返回的时区ID的一些示例是:
Timezone ID = Etc/GMT+12 Timezone ID = Etc/GMT+11 Timezone ID = MIT Timezone ID = Pacific/Apia Timezone ID = Pacific/Midway Timezone ID = Pacific/Niue Timezone ID = Pacific/Pago_Pago Timezone ID = Pacific/Samoa Timezone ID = US/Samoa ...