Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor TimeUtil: use Java 8 Date-Time API and improve time intervals #1017

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

bertm
Copy link
Contributor

@bertm bertm commented Nov 30, 2024

The time intervals were subtly broken:

  • Parsing 0.1s would yield 1 ms instead of the correct 100 ms. Fix this by parsing the seconds.millis as fractional seconds.
  • Formatting would format fractional seconds locale-sensitively where parsing would assume point as a decimal separator, so toMillis(fromMillis(...)) would fail depending on locale. Fix this by always formatting in the root locale (decimal point).

As a tiny bonus, time interval parsing is now approximately 3x faster.

The time intervals were subtly broken:
* Parsing 0.1s would yield 1 ms instead of the correct 100 ms.
  Fix this by parsing the seconds.millis as fractional seconds.
* Formatting would format fractional seconds locale-sensitively
  where parsing would assume point as a decimal separator, so
  toMillis(fromMillis(...)) would fail depending on locale. Fix
  this by always formatting in the root locale (decimal point).

As a tiny bonus, time interval parsing is now approximately 3x faster.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant