Document use of @⁠EnabledForJreRange

master
Sam Brannen 1 year ago
parent
commit
024cbb70cc
  1. 5
      Date-and-Time-Formatting-with-JDK-20-and-higher.md

5
Date-and-Time-Formatting-with-JDK-20-and-higher.md

@ -34,6 +34,11 @@ The Spring team also recommends the use of UTF encoding whenever possible – fo @@ -34,6 +34,11 @@ The Spring team also recommends the use of UTF encoding whenever possible – fo
Within application code or tests you may need to match against an input string to determine if the provided text adheres to the format you expect; however, the input string may contain a narrow non-breaking space where you have traditionally expected a standard space. To address use cases like that, you can use the `\p{Zs}` regular expression pattern to match against any Unicode space character. For example, `12:00\\p{Zs}PM` matches against `"12:00<SPACE>PM"` and `"12:00<NNBSP>PM"`, where `<SPACE>` is a standard space and `<NNBSP>` is a narrow non-breaking space (`"\u202F"`).
If you are using JUnit Jupiter as your testing framework and wish to run certain tests on JDK versions before or after the CLDR changes in the JDK, you can annotate a test class or test method as follows.
- `@EnabledForJreRange(max = JAVA_19)`: enabled on all JDKs before JDK 20.
- `@EnabledForJreRange(min = JAVA_20)`: enabled on all JDKs after and including JDK 20.
The following sections provide guidance on lenient parsing for `@DateTimeFormat`, `SimpleDateFormat`, and `DateTimeFormatter`. Note, however, that you can also consider implementing and registering a custom `java.util.spi.LocaleServiceProvider` to support more advanced use cases. See [JEP 252](https://openjdk.org/jeps/252) for an example.
#### Lenient `@DateTimeFormat` Configuration

Loading…
Cancel
Save