Skip to content

Conversation

@yoikawa
Copy link
Contributor

@yoikawa yoikawa commented Jul 14, 2025

IllegalArgument is thrown from BaseLocalizer.JdkFormatFixer.checkAM if all condition below are met:

  • Java is started with -Djava.locale.proviers=SPI option (uses ICU over JDK)
  • uses JDK as FormatFixer (default behavior)
  • Locale is "zh-TW"

ICU version of SimpleDateFormat.toPattern() returns "y/M/d Bh:mm" where the 'B' is not supported by JDK.

The method did not check'B' along with 'a' as AM/PM notation and pass the pattern to JDK's new SimpleDateFormat that throws this exception.

// fix if neither 'H' or 'k' (24-hour) does not present, and if 'a' or 'B'
// (AM/PM notation) doesn't exist. ICU version of SimpleDateFormat may return 'B' for zh-TW
if ((p.indexOf('H') == -1 && p.indexOf('k') == -1) && (p.indexOf('a') == -1 && p.indexOf('B') == -1)) {
df.applyPattern(p + " a");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • add extra check for 'B'
  • no need to construct new SimpleDateFormat, but just call applyPattern(String) here.

@yoikawa yoikawa merged commit 5fcd14e into main Jul 14, 2025
4 checks passed
@yoikawa yoikawa deleted the fix-exception branch July 14, 2025 08:54
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.

2 participants