【发布时间】:2014-05-29 09:55:08
【问题描述】:
我假设所有系统(Windows、Mac、Linux、Solaris、SunOS、HP-UX、AIX、FreeBSD、NetWare、OS/400 等)都具有时区值。因此我编写了以下程序来获取系统的本地时区:
import java.text.DateFormat;
public class LocalTimeZone {
public static void main(String[] args) {
String local_time_zone;
DateFormat df = DateFormat.getTimeInstance(DateFormat.FULL);
local_time_zone=df.getTimeZone().getID();
System.out.println("local time zone: " + local_time_zone);
}
}
输出:
local time zone: Asia/Calcutta
时区值在我的机器中设置,因此输出显示我的本地时区。
能有没有设置时区的机器吗?
【问题讨论】: