TimeZone.getTimeZone
should be passed correct timezone IDs JAVA-E1093java.util.TimeZone.getTimeZone()
should not be passed invalid time zone identifier strings, as this will make it fail silently and return GMT instead.
Java cannot check for invalid timezones at compile time, so it is up to the developer to ensure that the string provided is actually valid. To avoid accidentally using an invalid time zone, it is recommended to select from a known list of timezone identifiers, such as those provided by the ZoneId.getAvailableZoneIds()
method.
TimeZone tz = TimeZone.getTimeZone("invalid/timezone"); // tz is assigned the GMT time zone.
Use a valid timezone string.
TimeZone tz = TimeZone.getTimeZone("America/New_York");
java.util.TimeZone.getTimeZone()