Skip to content

Add recipe to find locale-sensitive date/time formatting affected by JDK 20+ CLDR changes#967

Merged
timtebeek merged 2 commits intomainfrom
find-locale-datetime-formats
Jan 16, 2026
Merged

Add recipe to find locale-sensitive date/time formatting affected by JDK 20+ CLDR changes#967
timtebeek merged 2 commits intomainfrom
find-locale-datetime-formats

Conversation

@timtebeek
Copy link
Member

Summary

  • Adds FindLocaleDateTimeFormats search recipe that detects usages of locale-based date/time formatting APIs affected by JDK 20+ CLDR 42 changes
  • Starting with JDK 20, the space before AM/PM changed from regular space to narrow no-break space (NNBSP, \u202F)
  • This can cause parsing issues when user input contains regular spaces but the formatter expects NNBSP

Detected APIs

  • DateFormat.getTimeInstance()
  • DateFormat.getDateTimeInstance()
  • DateFormat.getInstance()
  • DateTimeFormatter.ofLocalizedTime()
  • DateTimeFormatter.ofLocalizedDateTime()

References

Test plan

  • Unit tests for all detected method patterns
  • Negative tests for explicit patterns (DateTimeFormatter.ofPattern()) and date-only formatting (DateFormat.getDateInstance())
  • Multiple usages test

🤖 Generated with Claude Code

…JDK 20+ CLDR changes

Starting with JDK 20, Unicode CLDR 42 changed the space before AM/PM from a
regular space to a narrow no-break space (NNBSP, \u202F). This can cause
parsing issues when user input contains regular spaces.

This search recipe detects usages of:
- DateFormat.getTimeInstance()
- DateFormat.getDateTimeInstance()
- DateFormat.getInstance()
- DateTimeFormatter.ofLocalizedTime()
- DateTimeFormatter.ofLocalizedDateTime()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-project-automation github-project-automation bot moved this to In Progress in OpenRewrite Jan 15, 2026
@timtebeek timtebeek added recipe Recipe requested java 21+ labels Jan 15, 2026
@timtebeek timtebeek moved this from In Progress to Ready to Review in OpenRewrite Jan 15, 2026
@timtebeek timtebeek requested a review from MBoegers January 16, 2026 12:50
Copy link
Contributor

@MBoegers MBoegers left a comment

Choose a reason for hiding this comment

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

LGTM

@timtebeek timtebeek merged commit 90b4e63 into main Jan 16, 2026
2 checks passed
@timtebeek timtebeek deleted the find-locale-datetime-formats branch January 16, 2026 13:04
@github-project-automation github-project-automation bot moved this from Ready to Review to Done in OpenRewrite Jan 16, 2026
mergify bot added a commit to robfrank/linklift that referenced this pull request Jan 25, 2026
…25.0 to 3.26.0 [skip ci]

Bumps [org.openrewrite.recipe:rewrite-migrate-java](https://github.com/openrewrite/rewrite-migrate-java) from 3.25.0 to 3.26.0.
Release notes

*Sourced from [org.openrewrite.recipe:rewrite-migrate-java's releases](https://github.com/openrewrite/rewrite-migrate-java/releases).*

> 3.26.0
> ------
>
> What's Changed
> --------------
>
> * Also change managed dependency classifier to ehcache to avoid breaking multi module projects by [`@​dsgrieve`](https://github.com/dsgrieve) in [openrewrite/rewrite-migrate-java#963](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/963)
> * fix `IndexOutOfBoundsException` that occurs in `UseNoArgsConstructor` when visiting record compact constructor method by [`@​zakaria-shahen`](https://github.com/zakaria-shahen) in [openrewrite/rewrite-migrate-java#964](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/964)
> * Replace `getDisplayName()` and `getDescription()` methods with fields by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#966](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/966)
> * Use `var` for variables initialized with type casts by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#965](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/965)
> * Add recipe to find locale-sensitive date/time formatting affected by JDK 20+ CLDR changes by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#967](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/967)
> * Normalize version numbers in `FindJavaVersion` by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#969](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/969)
> * Fix JavaxWebXmlToJakartaWebXml regex to match multiline schemaLocation by [`@​timtebeek`](https://github.com/timtebeek) in [openrewrite/rewrite-migrate-java#971](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/971)
>
> New Contributors
> ----------------
>
> * [`@​dsgrieve`](https://github.com/dsgrieve) made their first contribution in [openrewrite/rewrite-migrate-java#963](https://redirect.github.com/openrewrite/rewrite-migrate-java/pull/963)
>
> **Full Changelog**: <openrewrite/rewrite-migrate-java@v3.25.0...v3.26.0>


Commits

* [`424b525`](openrewrite/rewrite-migrate-java@424b525) Fix JavaxWebXmlToJakartaWebXml regex to match multiline schemaLocation ([#971](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/971))
* [`4beeb8a`](openrewrite/rewrite-migrate-java@4beeb8a) Normalize version numbers in `FindJavaVersion` ([#969](https://redirect.github.com/openrewrite/rewrite-migrate-java/issues/969))
* [`1180190`](openrewrite/rewrite-migrate-java@1180190) [Auto] SDKMAN! Java candidates as of 2026-01-19T1023
* [`288ea96`](openrewrite/rewrite-migrate-java@288ea96) OpenRewrite recipe best practices
* [`c7f8d21`](openrewrite/rewrite-migrate-java@c7f8d21) Replace `getEstimatedEffortPerOccurrence()` method with field
* [`b22610d`](openrewrite/rewrite-migrate-java@b22610d) Replace `getTags()` method with field
* [`90b4e63`](openrewrite/rewrite-migrate-java@90b4e63) Add recipe to find locale-sensitive date/time formatting affected by JDK 20+ ...
* [`bb9adab`](openrewrite/rewrite-migrate-java@bb9adab) Update Gradle wrapper to 9.3.0
* [`da7c2e1`](openrewrite/rewrite-migrate-java@da7c2e1) Replace `Arrays.asList` with `List.of` in tests
* [`7a52f88`](openrewrite/rewrite-migrate-java@7a52f88) OpenRewrite recipe best practices
* Additional commits viewable in [compare view](openrewrite/rewrite-migrate-java@v3.25.0...v3.26.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=org.openrewrite.recipe:rewrite-migrate-java&package-manager=maven&previous-version=3.25.0&new-version=3.26.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

java 21+ recipe Recipe requested

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants