Skip to content

Conversation

@garydgregory
Copy link
Member

[LANG-1786] A lot of warnings on the console when using FastDateFormat
with JDK25

Add and use TimeZones.getTimeZone(String) as a way to avoid writing to the console on Java 25:

    /**
     * Delegates to {@link TimeZone#getTimeZone(String)} with special behavior on Java 25.
     * <p>
     * On Java 25, this methods delegates once to {@link TimeZone#getTimeZone(String)} for each short ID to avoid logging deprecation warning to system error.
     * </p>
     * <p>
     * On Java 25, this message is of the form:
     * </p>
     *
     * <pre>
     * WARNING: Use of the three-letter time zone ID "the-short-id" is deprecated and it will be removed in a future release
     * </pre>
     *
     * @param id Same as {@link TimeZone#getTimeZone(String)}.
     * @return Same as {@link TimeZone#getTimeZone(String)}.
     * @since 3.20.0
     */
    public static synchronized TimeZone getTimeZone(final String id) {

Before you push a pull request, review this list:

  • Read the contribution guidelines for this project.
  • Read the ASF Generative Tooling Guidance if you use Artificial Intelligence (AI).
  • I used AI to create any part of, or all of, this pull request.
  • Run a successful build using the default Maven goal with mvn; that's mvn on the command line by itself.
  • Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. This may not always be possible, but it is a best practice.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Each commit in the pull request should have a meaningful subject line and body. Note that a maintainer may squash commits during the merge process.

@garydgregory garydgregory changed the title Lang 1786 cache short ids log once [LANG-1786] Cache short ids and log once Nov 6, 2025
@LI123456mo
Copy link

Hi everyone
It is my first time to join here , Just new and am looking foward to learn new things here and also offer some help

@lprimak
Copy link

lprimak commented Nov 6, 2025

Looking at this, it introduces a synchronized method for the timezone. Does this have negative overall performance implications?
The cache is a concurrent map, so maybe this can be avoided?

FastDateFormat on Java 25

- Use a boolean system property when on Java 25 called
"FastDateParser.ignoreTimeZoneShortIDs" if present
- Remove unnecessary synchronized
- Extract a constant
@garydgregory
Copy link
Member Author

Looking at this, it introduces a synchronized method for the timezone. Does this have negative overall performance implications? The cache is a concurrent map, so maybe this can be avoided?

I removed the synchronized on the method.

@LI123456mo
Copy link

LI123456mo commented Nov 6, 2025 via email

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.

3 participants