Quick revision
The short answer
The JDK takes its locale data from the Unicode CLDR project by default since JDK 9, and the CLDR version that came with JDK 20 changed English time formats so that the space before AM or PM is a narrow no-break space, U+202F, instead of a normal space. Localized formatting now produces that character, and a strict parser expecting a normal space fails as soon as one side of an exchange uses the new data. Data exchanged between systems should use fixed formats such as ISO 8601, never localized styles; the COMPAT provider was only a temporary escape hatch and has since been removed, so we protect upgrades with format and parse tests on fixed locales and by reading the locale data changes in release notes.
What to remember
In this answer, we saw that the JDK has used CLDR locale data by default since JDK 9 and that the CLDR version in JDK 20 put a narrow no-break space, U+202F, before AM and PM in English time formats. Localized styles now produce it, and a parser with a literal normal space fails when a partner using the new data sends it. We normalised input as a stopgap, noted that the COMPAT provider is deprecated and removed in recent JDKs, moved machine-to-machine data to fixed ISO 8601 formats, and protected future upgrades with golden-value tests and release-note reviews.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The JDK takes its locale data from the Unicode CLDR project by default since JDK 9, and the CLDR version that came with JDK 20 changed English time formats so that the space before AM or PM is a narrow no-break space, U+202F, instead of a normal space. Localized formatting now produces that character, and a strict parser expecting a normal space fails as soon as one side of an exchange uses the new data. Data exchanged between systems should use fixed formats such as ISO 8601, never localized styles; the COMPAT provider was only a temporary escape hatch and has since been removed, so we protect upgrades with format and parse tests on fixed locales and by reading the locale data changes in release notes.
Why this question is asked
A JDK upgrade is supposed to be invisible to business logic, and most of the time it is. Locale data is the exception, because it is not code we wrote; it is a large database of formats that the JDK updates from an outside project. When that data changes, formatting output changes and parsing can start failing, with no change on our side. Interviewers use this scenario to see whether we can diagnose a failure that has nothing to do with our code, and whether we know the rule that prevents it. In this answer, we will recap where locale data comes from, see what changed, work out how it reaches a service with an explicit pattern, and then look at short-term fixes, the real fix and how to make upgrades safe.
1A Quick Recap: Where the JDK Gets Locale Data
Formatting a date or number for a locale needs data: month names, the order of day and month, the decimal separator, and the exact characters around AM and PM. The JDK used to ship its own data, now called COMPAT. Since JDK 9 (JEP 252), the default comes from CLDR, the Common Locale Data Repository maintained by the Unicode Consortium, which is also used by browsers, operating systems and ICU. Each JDK release may take a newer CLDR version, and CLDR changes its data whenever language experts decide a convention should be represented more precisely.
One such change arrived in CLDR 42, which JDK 20 adopted. In English time formats, the space between the time and AM or PM became a narrow no-break space, U+202F. It looks almost like a normal space but is a different character, chosen so that the time never wraps onto two lines.
2Seeing the Change in Formatted Output
We can make the invisible character visible by printing the character codes of a localized time.
Notice the 202f in the list. The same happens with the old DateFormat.getTimeInstance. Index 4 in the exception is exactly where the parser expected the narrow space and found a normal one. So output that some customers say looks different, such as a time that now refuses to wrap or a column that no longer matches in a text comparison, comes from code paths that use localized styles.
3How It Reaches a Service With an Explicit Pattern
Our parser uses ofPattern("h:mm a", Locale.US). In an explicit pattern, the space is a literal character that we typed, so this formatter still writes and expects a normal space on JDK 21. That tells us where to look: the input changed. The partner's system most likely upgraded its own JDK, or another runtime with recent CLDR data, and formats times with a localized style, so it now sends 3:30 PM with U+202F in it. Our literal space does not match it.
4 messages in order. Play them, or step through them one at a time.
Neither side changed its code. The partner's locale data changed the character between the time and PM.
The same reasoning works in reverse for the output that changed: any place in our service that formats with ofLocalizedTime, DateFormat or a template engine's locale-aware formatting now writes U+202F, and a partner parsing with a normal space will fail on their side. The bug is not in either JDK; it is in exchanging data in a human, locale-dependent format.
4Short-Term Fixes
To stop the failures today, we can normalise the input before parsing, replacing U+202F and U+00A0 with a normal space. This is safe because the value is meant to be the same time either way.
Another option some teams used was the system property -Djava.locale.providers=COMPAT, which brought back the pre-CLDR data. It is not a lasting fix: COMPAT was deprecated and JDK 21 prints a warning that it will be removed, and it was removed in a later release (JDK 23; check your version). It also changes every locale-dependent format in the whole JVM, not just the one that broke, so it can introduce differences elsewhere.
5The Real Fix: Fixed Formats Between Machines
Formats from locale data are designed for people, and they will keep changing as CLDR improves. Data that one program sends to another needs a contract that never changes. For times and dates that contract is ISO 8601: 15:30 or 15:30:00, written and read with DateTimeFormatter.ISO_LOCAL_TIME, ISO_LOCAL_DATE or ISO_OFFSET_DATE_TIME, which do not depend on any locale. If a partner insists on a 12-hour format, we agree on an explicit pattern with an explicit Locale on both sides and write it into the interface specification, including which space character is used. Localized styles stay at the very edge, in the UI and in human-facing documents.
6Making Upgrades Safe
We cannot freeze locale data, but we can notice its changes before customers do. We keep golden-value tests that format important values, such as a time, a date, an amount of money, with fixed locales and assert the exact output string, and round-trip tests that parse what we format. Those tests fail in CI when a JDK upgrade changes the data, which turns a production incident into a decision. Before every upgrade, we also read the internationalization section of the release notes, which announces CLDR version changes, and we run the full suite on the new JDK, including integration tests against recorded partner messages.
7Follow-up questions
Why should data exchanged between systems not depend on locale at all?
Because a locale-dependent format has two moving parts that neither system controls: the locale settings of each machine and the version of the locale data. A value formatted in German has a comma as the decimal separator, a value formatted in English has a dot, and a CLDR update can change spaces, month abbreviations or AM and PM markers at any upgrade. A machine format such as ISO 8601 for dates, a dot-decimal number, and amounts in minor units with a currency code mean the same thing everywhere and forever, so both sides can be upgraded independently. Locale belongs only at the point where a person reads the value.
How can we see invisible characters like U+202F when debugging?
By printing the character codes instead of the string, for example s.chars().mapToObj(Integer::toHexString).toList(), or by logging the value with a JSON serializer that escapes non-ASCII characters. In an exception like could not be parsed at index 4, the index tells us exactly which character to look at. Hex dumps of the raw request body, from a tool such as xxd, show the UTF-8 bytes e2 80 af for U+202F.
Why did the JDK switch to CLDR in the first place?
Because CLDR is the shared, actively maintained source of locale conventions used by most of the industry, including browsers and operating systems, and it covers far more locales than the JDK's own data did. Using it means Java formats dates and numbers the same way as the rest of the user's software. The cost is that we inherit its updates, which is a good trade for human-facing text and a reason to keep machine formats away from it.
8Conclusion
In this answer, we saw that the JDK has used CLDR locale data by default since JDK 9 and that the CLDR version in JDK 20 put a narrow no-break space, U+202F, before AM and PM in English time formats. Localized styles now produce it, and a parser with a literal normal space fails when a partner using the new data sends it. We normalised input as a stopgap, noted that the COMPAT provider is deprecated and removed in recent JDKs, moved machine-to-machine data to fixed ISO 8601 formats, and protected future upgrades with golden-value tests and release-note reviews.
Open with
The likely cause is a locale data change, not our code. Since JDK 9 the JDK uses CLDR, the Unicode locale data repository, by default, and JDK 20 picked up CLDR 42, where English time formats put a narrow no-break space, U+202F, between the time and AM or PM instead of a normal space.
Then, if they want more
Anything formatted with a localized style, like ofLocalizedTime or DateFormat, now produces that character, which is why some output looks different.
With an explicit pattern like h:mm a, the space is a literal, so our own formatter still uses a normal space; the parse failures mean the partner's input changed, probably because their side upgraded and formats with localized data, and our literal space doesn't match U+202F.
I'd confirm it by printing the character codes of a failing value; the exception index points at that character. Short term, I'd normalise U+202F and the no-break space to a normal space before parsing. The COMPAT provider flag was a temporary option, but it's deprecated, changes every format in the JVM, and has been removed in recent JDKs.
The real fix is that machine-to-machine data shouldn't use locale formats at all: use ISO 8601, like ISO_LOCAL_TIME, or an explicitly agreed pattern with an explicit locale written into the contract.
For upgrades, I keep golden tests that format and parse key values with fixed locales, so CI fails when locale data changes, and I read the internationalization notes in each JDK release.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 21, Java 20, Java 9, Java 17
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- The Java Language Specification, Java SE 21, Java SE 21 API documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "After upgrading from JDK 17 to JDK 21, a service that parses times like "3:30 PM" with...": https://scrivio-interview-library.netlify.app/java/strings/854876d971/