> Please review this PR and [CSR](https://bugs.openjdk.org/browse/JDK-8333920) > which corrects a bug where NumberFormat cannot successfully parse values in > integer only mode, when the format expects a suffix. > > For example, > > // a format that expects a currency suffix > var fmt = NumberFormat.getCurrencyInstance(Locale.FRANCE); > fmt.setParseIntegerOnly(true); > failFmt.parse("5,00 €"); // throws ParseException when you would have > expected 5 returned > > > When parsing in integer only mode, instead of breaking upon a decimal symbol > encounter, we should store the index but continue to fully parse so that we > can verify the entire string and increment our position to search for and > match the suffix. Upon a successful suffix match, we can then set > `ParsePosition.index` back to the stored decimal index. > > It should be noted that CompactNumberFormat did previously have code that > would traverse the rest of the String, to allow matching of the suffix. The > difference is that NumberFormat returns the index upon decimal symbol > encounter, while CompactNumberFormat was implemented to return the index > reflected by the entire string traversal. Such differences cannot be > standardized due to behavioral compatibility concerns. > > Thus while parsing in integer only, CNF sets index to the > `Position.fullPos()`, while DF sets index to the `Position.intPos()`.
Justin Lu has updated the pull request incrementally with one additional commit since the last revision: specification improvements ------------- Changes: - all: https://git.openjdk.org/jdk/pull/19664/files - new: https://git.openjdk.org/jdk/pull/19664/files/c692b4fc..8579a0f6 Webrevs: - full: https://webrevs.openjdk.org/?repo=jdk&pr=19664&range=01 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=19664&range=00-01 Stats: 9 lines in 2 files changed: 4 ins; 3 del; 2 mod Patch: https://git.openjdk.org/jdk/pull/19664.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/19664/head:pull/19664 PR: https://git.openjdk.org/jdk/pull/19664