You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To show dates and times in the user's time zone, you need a java.time.ZoneId. ExtendedClientDetails offers the pieces, getTimeZoneId() (may be null) and getTimezoneOffset(), but not the ZoneId itself, so every app writes the same conversion. The getBrowserTime() javadoc even spells it out:
The fallback there is the server's time zone, which is usually wrong for the user. The browser has already reported its offset, which is a far better fallback.
Describe the solution you'd like
publicZoneIdgetZoneId()
It returns ZoneId.of(getTimeZoneId()) when the browser reported a zone ID; otherwise the ZoneOffset from getTimezoneOffset(). Never null. The zone ID is preferred over the offset since only the ID gets daylight saving right for other dates than today.
Things worth deciding in the PR: whether to fall back to the offset also when ZoneId.of() rejects an ID the JVM doesn't know, and whether the getBrowserTime() javadoc should then use getZoneId().
This is a valid request. ExtendedClientDetails already has everything needed: getTimeZoneId() (nullable) and getTimezoneOffset(). The getBrowserTime() javadoc currently suggests ZoneId.systemDefault() as the fallback, but that is the server's zone, which is usually the wrong one for the user.
Proposed solution (implemented in a draft PR that links this issue):
publicZoneIdgetZoneId()
Returns ZoneId.of(getTimeZoneId()) when the browser reported an ID. This is preferred because only a region-based zone gets DST right for dates other than today.
Otherwise returns ZoneOffset.ofTotalSeconds(getTimezoneOffset() / 1000). This offset already includes DST that is in effect right now.
Never returns null.
On the open questions:
Should an ID the JVM doesn't know fall back to the offset? Yes. ZoneId.of throws DateTimeException (e.g. an old JDK tzdb meeting a newly renamed zone, or a garbage value from the client). Throwing from a getter over client-supplied data would be a trap, and the offset is still correct for "now". An out-of-range offset (only possible with a tampered payload) falls back to UTC, which matches the existing "0 if not available" contract of getTimezoneOffset().
Should the getBrowserTime() javadoc use it? Yes. The example becomes details.getBrowserTime().atZone(details.getZoneId()).
Activity
totally-not-ai commentedon Sep 29, 2026
This is a valid request.
ExtendedClientDetailsalready has everything needed:getTimeZoneId()(nullable) andgetTimezoneOffset(). ThegetBrowserTime()javadoc currently suggestsZoneId.systemDefault()as the fallback, but that is the server's zone, which is usually the wrong one for the user.Proposed solution (implemented in a draft PR that links this issue):
ZoneId.of(getTimeZoneId())when the browser reported an ID. This is preferred because only a region-based zone gets DST right for dates other than today.ZoneOffset.ofTotalSeconds(getTimezoneOffset() / 1000). This offset already includes DST that is in effect right now.null.On the open questions:
ZoneId.ofthrowsDateTimeException(e.g. an old JDK tzdb meeting a newly renamed zone, or a garbage value from the client). Throwing from a getter over client-supplied data would be a trap, and the offset is still correct for "now". An out-of-range offset (only possible with a tampered payload) falls back toUTC, which matches the existing "0 if not available" contract ofgetTimezoneOffset().getBrowserTime()javadoc use it? Yes. The example becomesdetails.getBrowserTime().atZone(details.getZoneId()).mvysny commentedon Sep 29, 2026
I agree with both of your suggestions in the open questions. Totally-not-ai, please implement and create a PR.
mvysny commentedon Sep 29, 2026
Eh, totally-not-ai is not listening, so I enlisted my own totally-not-ai :-D
feat: add ExtendedClientDetails.getZoneId() (vaadin#26036)