ZoneId.of()
should be passed a valid timezone identifier JAVA-E1092java.time.ZoneId.of()
should not be passed invalid time zone identifier strings, as this will cause exceptions to be thrown at runtime.
ZoneId
doesn't check the input string at compile-time, so it is up to the developer to ensure that the string
provided is actually valid. To avoid errors, it is recommended to select from a known list of timezone
identifiers, such as those provided by
the ZoneId.getAvailableZoneIds()
method.
ZoneId zoneId = ZoneId.of("invalid/timezone");
Here, an invalid timezone string is passed to ZoneId.of()
. This would cause a ZoneRulesException
to be thrown.
Use a valid timezone string.
ZoneId zoneId = ZoneId.of("America/New_York");
java.time.ZoneId.of()