I've found myself having to hardcode timezones for...
# random
c
I've found myself having to hardcode timezones for one of my projects.
Copy code
ZoneId.of("America/Los_Angeles")
That in itself is fine. But it got me wondering why isn't there just some enum available? Is there or is there a reason timezones are stringly typed?
e
tzdb gets updated more often than any programming language, and the updates are not always additive
c
intersting. i guess maybe im confused how tzdb gets updated out of band
like. once im compiling my app. where would it pull the updated tzdb from?
e
depends on your platform. and with Java, like many things it's a SPI so it could come from multiple sources…
the oracle jre/jdk ships with a static tzdb, but provides updates, https://www.oracle.com/java/technologies/javase/tzupdater-readme.html or a different provider could be installed which gets them from elsewhere on the system
đź‘€ 1
c
gotcha. okay. this makes more sense then. thanks for teaching
e
you could hypothetically ship your own tzdb with your application (as https://www.zacsweers.dev/ticktock-desugaring-timezones/ does, although it's basically obsoleted by https://android-developers.googleblog.com/2024/03/better-faster-stronger-time-zone-updates-on-android.html). but just to be clear,
like. once im compiling my app. where would it pull the updated tzdb from?
it doesn't even matter at compile time, the lookup is happening at runtime
âž• 1