How do you get the client timezone in version 14?

Previous versions of Vaadin provided methods to get the timezone offset from the browser.


Those methods don’t appear to exist in version 14.
How do you get the browser timezone (or timezone offset) in version 14?



The executeJavaScript() method is deprecated.
Is there a replacement method?

What I do is that I call Page.retrieveExtendedClientDetails(); when Vaadin calls me back with ExtendedClientDetails I store that information into the session.

Afterwards you can use the similar code to retrieve the time zone:

val ExtendedClientDetails.timeZone: ZoneId
    get() = if (!timeZoneId.isNullOrBlank()) {
        // take into account zone ID. This is important for historical dates, to properly compute date with daylight savings.
    } else {
        // fallback to time zone offset
        ZoneOffset.ofTotalSeconds(timezoneOffset / 1000)


Due to the bootstrapping process differences V14 doesn’t get all the information from the client like V8 did.
To get the extended details you should use:

UI.getCurrent().getPage().retrieveExtendedClientDetails(extendedClientDetails -> {

From the returned extendedClientDetails you should find the same extended data as was available in V8.

The JavaScript execution has changed to UI.getCurrent().getPage().executeJs(String expression, Serializable... parameters) or then you can use Component.getElement().executeJs(String expression, Serializable... parameters)

  • Mikael

Perfect. Thanks!