当我写这段代码时:
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("EST"));
System.out.println(cal.getTimeZone().getDisplayName());
输出是
Eastern Standard Time
但是当我写这段代码时:
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("est"));
System.out.println(cal.getTimeZone().getDisplayName());
我得到的输出是:
GMT-05:00
在设置时给出像“EST”和“est”这样的参数有什么区别TimeZone.setTimeZone(String str)
(str
在调用被认为是CASE SENSITIVE时要传递)?
API 没有提及任何相关内容:
getTimeZone
public static TimeZone getTimeZone(String ID)
Gets the TimeZone for the given ID.
Parameters:
ID - the ID for a TimeZone, either an abbreviation such as "PST", a full name such as "America/Los_Angeles", or a custom ID such as "GMT-8:00".
Note that the support of abbreviations is for JDK 1.1.x compatibility only and full names should be used.
Returns:
the specified TimeZone, or the GMT zone if the given ID cannot be understood.
注意:我尝试使用IST
和ist
字符串。对于它给出的IST
字符串Indian Standard Time
,对于ist
它给出Greenwich Mean Time