-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b04
-
generic
-
generic
-
Verified
The JDK defines two concrete subclasses of NumberFormat, DecimalFormat and CompactNumberFormat.
Unlike CompactNumberFormat, DecimalFormat fails parsing in integer only mode if the expected format contains a suffix and the parse string contains a decimal symbol. The implementation does not fully traverse the parse string upon encountering a decimal symbol. Thus the parse will always fail, since the suffix can not be matched.
Instead of stopped the traversal during a decimal symbol encounter, we should continue, but stop appending digits to the digitList.
A common example of this bug would be a percent instance parsing a string value that has a fractional portion.
Adding on to this, further clarification should be added to make clear that while parsing in integer only mode, the ParsePosition index under DecimalFormat reflects the decimal symbol, but is not the case for CompactNumberFormat. In that case, the index is still reflected by the end of the parse string. Such differences can not be remedied due to compatibility concerns.
Unlike CompactNumberFormat, DecimalFormat fails parsing in integer only mode if the expected format contains a suffix and the parse string contains a decimal symbol. The implementation does not fully traverse the parse string upon encountering a decimal symbol. Thus the parse will always fail, since the suffix can not be matched.
Instead of stopped the traversal during a decimal symbol encounter, we should continue, but stop appending digits to the digitList.
A common example of this bug would be a percent instance parsing a string value that has a fractional portion.
Adding on to this, further clarification should be added to make clear that while parsing in integer only mode, the ParsePosition index under DecimalFormat reflects the decimal symbol, but is not the case for CompactNumberFormat. In that case, the index is still reflected by the end of the parse string. Such differences can not be remedied due to compatibility concerns.
- csr for
-
JDK-8333920 NumberFormat integer only parsing breaks when format has suffix
- Closed
- duplicates
-
JDK-4630856 [Fmt-Nu] Fail to parse integer portion from de-DE and fr-FR currencies
- Closed
-
JDK-4663985 [Fmt-Nu] setParseIntegerOnly(true) is inconsistent when parsing percent amount
- Closed
- relates to
-
JDK-8335668 NumberFormat integer only parsing should throw exception for edge case
- Resolved
(1 links to)