Skip to content

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
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

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants