<i18n dev> RFR: 8349000: Performance improvement for Currency.isPastCutoverDate(String)

Naoto Sato naoto at openjdk.org
Fri Jan 31 18:56:47 UTC 2025


On Thu, 30 Jan 2025 19:27:30 GMT, Justin Lu <jlu at openjdk.org> wrote:

> Please review this PR which improves the performance of cut-over date checking when the user supplies a properties override via the `java.util.currency.data` sys prop. Replacing the `SimpleDateFormat` with a _java.time_ alternative has better performance. It should be noted that this method is only entered when the string `s` is confirmed to adhere to the format: `yyyy-MM-ddTHH:mm:ss`.
> 
> An alternative is using `LocalDateTime.of(..)` and extracting the date/time values ourselves from `s` with the known positions which is considerably faster but not as concise.

Looks good. Since this code does not run in normal situations (only works when users provide a custom currency properties file), further (not concise) performance refactor may not be significant.

src/java.base/share/classes/java/util/Currency.java line 1179:

> 1177:         }
> 1178: 
> 1179:         // cutOver adheres to: "yyyy-MM-ddTHH:mm:ss"

In java.time, `YEAR` is represented as `u`, so "uuuu" is more accurate.

-------------

PR Review: https://git.openjdk.org/jdk/pull/23374#pullrequestreview-2587539215
PR Review Comment: https://git.openjdk.org/jdk/pull/23374#discussion_r1937765445


More information about the i18n-dev mailing list