Correct ZoneId for eastern time (ET): either "US/Eastern" or "America/New_York"?

nimo23 :

I have to use the time zone "ET" (Eastern Time). In Java, there is no ZoneId.of("ET").

Which one should I use to represent the "ET" correctly:

ZoneId TIMEZONE_ET = ZoneId.of("US/Eastern");

or

ZoneId TIMEZONE_ET = ZoneId.of("America/New_York");
T.J. Crowder :

Given that your requirement is to use the "Eastern zone," I'd use US/Eastern, but note:

  • It's just a link to America/New_York.
  • This file in Paul Eggert's tz repo says those links are to link "old" names (such as US/Eastern) to current names. "Old" may well mean "deprecated" in this context. Paul Eggert is the TZ Coordinator for IANA's Time Zone list, so this is a clearly canonical source.

Given that, you're probably best off with America/New_York, but given that the change is listed as being from 1993, clearly the old names aren't going away any time soon.

Either will contain the DST rules, etc. On my system, for instance:

var zoneRules = ZoneId.of("US/Eastern").getRules();
System.out.println(zoneRules.isDaylightSavings(Instant.parse("2019-07-01T12:00:00Z"))); // true
System.out.println(zoneRules.isDaylightSavings(Instant.parse("2019-01-01T12:00:00Z"))); // false

Note that noon on July 1st is in DST, and noon on January 1st is not.

More:

In the IANA Time Zone Database files, I've found:

to2050.tzs:

Link America/New_York    US/Eastern

...which suggests the two are aliases (altough ZoneId#equals doesn't return true for them). Also, in northamerica they have:

# US eastern time, represented by New York

with notes citing the relevant law.

So it seems clear to me that at the moment, they're synonymous. It's also clear that US/Eastern is the "old name." Of course, in theory, New York could decide at some point not to be part of the Eastern timezone anymore (perhaps to be closer, time-wise, to the UK and Europe), but that seems really unlikely...

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=127275&siteId=1