Difference between EST and America/New_York time z

2019-01-17 13:45发布

Can somebody please tell, what's the difference between the following two statements:

TimeZone.getTimeZone("America/New_York")

and

TimeZone.getTimeZone("EST")

In other words, why is EST different from America/New_York. Also in my application, to get the current time zone in US, should I use America/New_York or EST.

2条回答
时光不老,我们不散
2楼-- · 2019-01-17 14:27

EST is half of the New York time zone, effectively. It's always in standard time - it doesn't have the daylight saving part. It's not really a proper time zone in its own right, IMO - it's the "standard" part of a fuller time zone. When writing about a time zone which is just a fixed offset and not related to a particular place, I'd prefer to use "Etc/GMT+5" or something similarly obviously-fixed. (I don't generally like even "Eastern Time" and the like, as different places which observe "Eastern Time" may vary in their DST transitions. It's a bit like calling an encoding "extended ASCII"... it tells you some information, but not quite enough.)

So if you want to know the actual local time for New York at any particular instant, use America/New_York.

In general, stay away from the abbreviations. From the documentation:

For compatibility with JDK 1.1.x, some other three-letter time zone IDs (such as "PST", "CTT", "AST") are also supported. However, their use is deprecated because the same abbreviation is often used for multiple time zones (for example, "CST" could be U.S. "Central Standard Time" and "China Standard Time"), and the Java platform can then only recognize one of them.

(Personally I'd also advise you to stay away from Date and Calendar, preferring to use Joda Time wherever possible. That's a different matter though, really.)

查看更多
爷、活的狠高调
3楼-- · 2019-01-17 14:41

EST is UTC - 5 hours. America/New_York is EST in the winter and E*D*T in the summer, so right now New York is UTC - 4 hours.

查看更多
登录 后发表回答