Is there a way to determine the user’s web browser’s current default time zone from within a Vaadin 8.1 app?
Preferably get a ZoneId object rather than the legacy class TimeZone.
The WebBrowser class offers getter methods for getCurrentDate(), getDSTSavings(), getRawTimezoneOffset(), getTimezoneOffset(), and isDSTInEffect(). But none of those are a ZoneId. A mere offset is not a time zone. A time zone is a history of offset-from-UTC for a particular region, covering past, present, and future changes such as Daylight Saving Time (DST).
I am aware that ultimately the only reliable way to know the user’s desired/expected time zone is to explicitly ask them in my app. But it would be nice to have a guess as a default.
The proposed duplicate is not a duplicate, asking about getting the current date-time whereas my Question is about the time zone. Furthermore, my Question asks about the modern java.time classes while the proposed Question is about the flawed legacy date-time classes.
An alternative for querying
WebBrowser(or any other Vaadin API) is to use the client IP address and use a online service to get the geo information, including ZoneId.See related Questions: