Arizona TimeZone Day Light Saving

I am trying to get the current time in specific time zones. I tried the following code.

Calendar j = new GregorianCalendar(TimeZone.getTimeZone("US/Mountain")); j.setTimeInMillis(Calendar.getInstance().getTimeInMillis()); System.out.println(j.get(Calendar.HOUR_OF_DAY)+":"+j.get(Calendar.MINUTE)); TimeZone tz = TimeZone.getTimeZone("US/Mountain"); System.out.println("tz.getRawOffset()"+tz.getRawOffset()/3600); System.out.println(tz.getDSTSavings()); System.out.println (tz.inDaylightTime(new Date())); 

The answer I received is surprising - 16:57 - wrong for 1 hour tz.getRawOffset () - 7000 3600000 true - why is daylight saving time true for Arizona? How to get the right wall clock for Phoenix or any other city in the USA?

+3
source share
3 answers

Arizona is in the time zone but does not perform DST . If you specify the US / Mountain time zone, then the computer will apply the rules that are used by most states in the Mountain time zone, including daylight saving time. To get the rules for Arizona (which do not include DST), you need the US / Arizona (or America / Phoenix) time zone. In a Navajo nation, you need a time zone called Navajo.

To rid yourself of some troubles, always try to use the names from "America / *", where you can choose the name of the city with the same time zone rules as the place that interests you.

To get the right time in the right time zone for any city in the world, you just need to look at the names in the Olson time zone database and their values. Although you usually think the term β€œtime zone” refers to the time of day in mid-winter (when everyone respects the standard time), in the Olson database the name of the time zone represents the entire history of daylight saving time and time zone rules for a specific area.

As an example, although Indiana now watches Eastern Time and watches DST (with the exception of a few counties near Chicago, which are centrally located as Chicago), until 2006 they did not observe DST. In order to cover this region, a time zone called "USA / Indiana" (or "America / Indianapolis") was created, even today you still want to use the time zone "America / Indianapolis" when talking about Indiana, so requests for dates and times before 2006 could be answered correctly.

+8
source

Most states of Arizona do not observe daylight saving time, but the Navajo nation within Arizona does observe daylight saving time.

+2
source

Information about the zone can be obtained directly for many large cities around the world. This includes Phoenix, which has the America / Phoenix zone identifier.

You can find a list of available zone identifiers using the TimeZone.getAvailableIDs () method or manually check the contents of the lib / zi JRE directory.

As other posters noted, information about the US / Arizona zone is different from the US / Mountains.

+1
source

All Articles