Skip to content

Commit

Permalink
fix: Update to jdk21 - EXO-71474 - Meeds-io/MIPs#91
Browse files Browse the repository at this point in the history
Before this fix, the simpleDateFormat for locale en is
MM/dd/yyyy, HH:mm:ss a
In jdk17 and under, the space between 'ss' and 'a' is a simple space
In JDK 21, the space was changed to '[NNBSP]a' ([OpenJDK information](https://bugs.openjdk.org/browse/JDK-8324665)) : , so the .contains(" a") returns always false

This commit add the test on '[NNBSP]a' in addition of ' a' in order to make it work on both jdk version

It also add surefire configuration to work with jdk21

Resolves Meeds-io/MIPs#91
  • Loading branch information
rdenarie committed May 3, 2024
1 parent fc22e82 commit 416ad84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 6 additions & 0 deletions component/common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} ${env.MAVEN_OPTS} --add-opens=java.base/jdk.internal.vm=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.security=ALL-UNNAMED</argLine>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ private void formatPattern(Locale locale) {
if (!getDatePattern_().contains("HH")) {
setDatePattern_(getDatePattern_().replaceAll("H", "HH"));
}
if (getDatePattern_().contains(" a")) {
setDatePattern_(getDatePattern_().replaceAll(" a", ""));
if (getDatePattern_().contains(" a") || getDatePattern_().contains(" a")) {
setDatePattern_(getDatePattern_().replaceAll(" a", "").replaceAll(" a", ""));
}

dateFormat_ = new SimpleDateFormat(getDatePattern_());
Expand Down

0 comments on commit 416ad84

Please sign in to comment.