feat: add ExtendedClientDetails.getBrowserTime() returning an Instant - #25480
Open
totally-not-ai[bot] wants to merge 3 commits into
Open
feat: add ExtendedClientDetails.getBrowserTime() returning an Instant#25480totally-not-ai[bot] wants to merge 3 commits into
totally-not-ai[bot] wants to merge 3 commits into
Conversation
…9291 Adds getBrowserTime(), which reports the estimated current time in the browser as a java.time.Instant instead of the obsolete java.util.Date. The value is a point on the time line, so it no longer depends on the default time zone of the server; combining it with getTimeZoneId() gives the date and time as shown on the end user's computer. getCurrentDate() is deprecated for removal and now delegates to the new method, so its behaviour is unchanged.
The three-long assertEquals(...) call bound to the float overload, where one ulp at epoch-milli magnitude is about 131 seconds, so the 1000 ms tolerance was meaningless. Compare with Math.abs instead, and document in getBrowserTime() that getTimeZoneId() may be null.
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Adds
ExtendedClientDetails.getBrowserTime(), which reports the estimated current time in the end user's browser as ajava.time.Instantinstead of the obsoletejava.util.Date.An
Instantis a point on the time line, so the value no longer depends on the default time zone of the server JVM. Combining it withgetTimeZoneId()gives the date and time as actually shown on the end user's computer.What changed
public Instant getBrowserTime()onExtendedClientDetails, computed from the existing client/server time delta.getCurrentDate()is deprecated for removal (@Deprecated(since = "25.3", forRemoval = true)) and now delegates togetBrowserTime(), so its behaviour is unchanged for existing callers.getTimeZoneId()may returnnullwhen the browser did not report a time zone, and shows the fallback needed when converting to aZonedDateTime.getCurrentDate()still agrees with it.InitialExtendedClientDetailsview and IT now exercisegetBrowserTime()instead ofgetCurrentDate().Test fix (first commit)
The existing three-argument
assertEquals(...)call inExtendedClientDetailsTestbound to thefloatoverload, where one ulp at epoch-milli magnitude is roughly 131 seconds — making the intended 1000 ms tolerance meaningless. The assertion now compares withMath.abs(...)against an explicitTIME_TOLERANCE_MSconstant.Use case
An application shows an audit log and wants each entry timestamped the way the user experienced it — a support agent in Helsinki looking at a log written from a browser in New York should see the New York wall-clock time, not the server's. Reading the browser clock as an
Instantplus the reported zone gives exactly that, without the result silently shifting depending on which time zone the server JVM happens to run in.API Changes
com.vaadin.flow.component.page.ExtendedClientDetails