跳到主要内容

简述Java SimpleTimeZone类是什么?

参考答案:

SimpleTimeZone提供公历日期支持
import java.util.TimeZone;

public class TimeZoneExample {
public static void main(String[] args) {
// 获取本地时区
TimeZone localZone = TimeZone.getDefault();
System.out.println("Local Time Zone: " + localZone.getDisplayName());

// 获取指定时区
TimeZone newYorkZone = TimeZone.getTimeZone("America/New_York");
System.out.println("New York Time Zone: " + newYorkZone.getDisplayName());

// 获取所有可用时区
String[] availableIDs = TimeZone.getAvailableIDs();
for (String id : availableIDs) {
System.out.println("Available Time Zone: " + id);
}
}
}