TimeZone
@Test
public void test() {
// 获得默认时区
TimeZone defaultTZ = TimeZone.getDefault();
// 获得上海时区
TimeZone shanghaiTZ = TimeZone.getTimeZone("Asia/Shanghai");
// 获得上海时区
TimeZone chinaTZ = TimeZone.getTimeZone("GMT+08:00");
// 获得UTC时区
TimeZone utc = TimeZone.getTimeZone("UTC");
// 获得GMT时区
TimeZone gmt = TimeZone.getTimeZone("GMT");
System.out.println(defaultTZ);
System.out.println(shanghaiTZ);
System.out.println(chinaTZ);
System.out.println(utc);
System.out.println(gmt);
}
结果: