timezone - Java: getTimeZone without returning a default value -


i have following instruction:

timezone zone = timezone.gettimezone("asia/toyo"); 

obviously, should return null, return default timezone, not desired behaviour case. java doc:

returns specified timezone, or gmt zone if given id cannot understood.

is there way corresponding timezone , null value if string not indicate valid timezone?

i don't find solution timezones , iterate on them.

instead of iterating use:

boolean exists = arrays.aslist(timezone.getavailableids()).contains("asia/toyo"); 

or:

boolean exists = arrays.stream(timezone.getavailableids()).anymatch("asia/toyo"::equals); 

if need often, putting available ids in hashset more efficient.


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -