The following code:
------
DateFormat dateFormatter =
DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.US);
TimeZone formatTZ = dateFormatter.getTimeZone();
System.out.println("2:Format=" + formatTZ.getID());
------
Produces
---------
2:Format=PST
--------------
You get the same result with 1 and 0 argument versions of getTimeInstance().
The expected result is the TimeZone of the local machine (in my case EST). You can achieve this result by getting the correct default via 'TimeZone.getDefault()' and then use the DateFormat.setTimeZone(). However it is extremely rare that you want to display the time using a TimeZone different from your own, so this logic should be built into the default.
------
DateFormat dateFormatter =
DateFormat.getTimeInstance(DateFormat.DEFAULT, Locale.US);
TimeZone formatTZ = dateFormatter.getTimeZone();
System.out.println("2:Format=" + formatTZ.getID());
------
Produces
---------
2:Format=PST
--------------
You get the same result with 1 and 0 argument versions of getTimeInstance().
The expected result is the TimeZone of the local machine (in my case EST). You can achieve this result by getting the correct default via 'TimeZone.getDefault()' and then use the DateFormat.setTimeZone(). However it is extremely rare that you want to display the time using a TimeZone different from your own, so this logic should be built into the default.
- duplicates
-
JDK-4069784 TimeZone.getDefault() returns incorrect time zome.
-
- Closed
-
- relates to
-
JDK-4057161 SimpleDateFormat.format() always shows time and time zones as PDT
-
- Closed
-