Skip to content

7.0.7 + Java 25: Fix for WARNING: Use of the three-letter time zone ID ... is deprecated and it will be removed in a future release#15432

Open
codeconsole wants to merge 7 commits intoapache:7.0.xfrom
codeconsole:time-zone-warning-fix
Open

7.0.7 + Java 25: Fix for WARNING: Use of the three-letter time zone ID ... is deprecated and it will be removed in a future release#15432
codeconsole wants to merge 7 commits intoapache:7.0.xfrom
codeconsole:time-zone-warning-fix

Conversation

@codeconsole
Copy link
Contributor

When using Java 25, all grails applications startup with

> Task :bootRun
WARNING: Use of the three-letter time zone ID "ACT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "AET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "AGT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "ART" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "AST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "BET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "BST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CAT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CNT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CTT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "EAT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "ECT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "EST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "HST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "IET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "IST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "JST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "MIT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "MST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "NET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "NST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PLT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PNT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PRT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "SST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "VST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "BET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "ART" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "JST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "VST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "IET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CNT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PLT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PNT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "EST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "EAT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "ECT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "PRT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CTT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "SST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "MST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "AST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "NST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "HST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "ACT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "BST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "AET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "IST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CST" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "NET" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "AGT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "CAT" is deprecated and it will be removed in a future release
WARNING: Use of the three-letter time zone ID "MIT" is deprecated and it will be removed in a future release
Grails application running at http://localhost:8090 in environment: development

This is due to the legacy FastDateFormat. This PR switches to java.time instead while maintaining backward compatibility.
The messages no longer occur after this fix.

…ed and it will be removed in a future release
@jdaugherty
Copy link
Contributor

We already merged the fix for this ...

@jdaugherty
Copy link
Contributor

I guess this is fixing it by changing to the new api instead of the lang update?

@codeconsole
Copy link
Contributor Author

I guess this is fixing it by changing to the new api instead of the lang update?

yeah, but are you sure updating the new api still fixes it?

@codeconsole
Copy link
Contributor Author

@jdaugherty if it was already fixed, why am I still getting the error using the latest 7.1.0-SNAPSHOT?

@jdaugherty
Copy link
Contributor

#15417 was merged 11hrs ago, I don't think we have merged up to 7.1.x yet

@jdaugherty
Copy link
Contributor

I''ve merged these changes up, can you retest before your changes and see if that fixed it? We will still need to take this API to ultimately update the usages, but I assume we'll do that in 7.1.x instead of 7.0.x? @jamesfredley

*/
public CalendarMarshaller() {
this(FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'", TimeZone.getTimeZone("GMT"), Locale.US));
this.legacyFormatter = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any known performance problems with the java.time.DateTimeFormatter vs the FastDateTimeFormatter?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@jdaugherty jdaugherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like any tests were added for this change and the default has been changed. This probably should be a 7.1 change.

@bito-code-review
Copy link

This question isn’t related to the pull request. I can only help with questions about the PR’s code or comments.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses Java 25 deprecation warnings by migrating from Apache Commons FastDateFormat (which uses deprecated three-letter timezone IDs) to Java's java.time.format.DateTimeFormatter API. The change maintains backward compatibility by preserving support for custom formatters through a legacyFormatter field.

Changes:

  • Replaced FastDateFormat with DateTimeFormatter in date/calendar marshallers
  • Added backward compatibility support for custom formatters via legacyFormatter field
  • Switched from deprecated three-letter timezone IDs to proper timezone handling

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
grails-converters/src/main/groovy/org/grails/web/converters/marshaller/xml/DateMarshaller.java Migrated XML date marshaller to use DateTimeFormatter with system default timezone
grails-converters/src/main/groovy/org/grails/web/converters/marshaller/json/DateMarshaller.java Migrated JSON date marshaller to use DateTimeFormatter with UTC timezone
grails-converters/src/main/groovy/org/grails/web/converters/marshaller/json/CalendarMarshaller.java Migrated JSON calendar marshaller to use DateTimeFormatter with UTC timezone

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


private final Format formatter;
private static final DateTimeFormatter DEFAULT_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS z")
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The date pattern has been changed from "yyyy-MM-dd HH:mm:ss.S z" (single 'S' for milliseconds) to "yyyy-MM-dd HH:mm:ss.SSS z" (triple 'S'). This changes the output format and is not backward compatible. A date with milliseconds value 5 would previously be formatted as "5" but will now be formatted as "005". This could break existing clients that parse these dates. Consider using the original pattern "yyyy-MM-dd HH:mm:ss.S z" to maintain backward compatibility.

Suggested change
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSS z")
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.S z")

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to revert or justify and add documentation for this change.

@jamesfredley
Copy link
Contributor

Since this doesn't fix a bug, but resolves annoying log lines when running on Java 25 by changing production code, I think this would be safer in 7.1.x.

Cover default DateTimeFormatter output, millisecond padding, UTC
conversion, legacy Format fallback, and supports() behavior for
json/DateMarshaller, json/CalendarMarshaller, and xml/DateMarshaller.

Assisted-by: Claude Code <Claude@Claude.ai>
@jdaugherty
Copy link
Contributor

@jamesfredley shouldn't we add functional / integration tests for this too given the impact? we're only testing the lower level stuff with this pr

Add DateMarshallerController and DateMarshallerSpec integration tests
to grails-test-examples/app1, exercising the DateTimeFormatter-based
marshallers end-to-end through the Grails converters pipeline.

Tests cover:
- JSON Date marshalling (ISO 8601 UTC format)
- JSON Calendar marshalling (ISO 8601 UTC format)
- XML Date marshalling (system default timezone format)
- 3-digit millisecond padding (.SSS) for both JSON and XML
- URL extension-based content negotiation (.json, .xml)

Assisted-by: Claude Code <Claude@Claude.ai>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

5 participants