We're updating the issue view to help you get more done. 

Make FormattedNumber#populateFieldPosition work when called multiple times (C, C++, and Java)


Currently, the FieldPosition is only ever populated with the first occurrence of a field. This is consistent with older APIs, which combined formatting with field position, such that calling the method a second time was expensive. However, with the decoupling of field position and formatting in the new API, the FieldPosition argument in populateFieldPosition could work sort-of like ParsePosition: if you call the method a second time, and the FieldPosition is already populated, it will give you the first field starting after the position currently stored in the FieldPosition.

For example, if you are looking for all of the grouping separators, you could do something like:

1 2 3 4 5 6 FieldPosition fpos = new FieldPosition(NumberFormat.Field.GROUPING_SEPARATOR); result.populateFieldPosition(fpos); while (fpos.getEndIndex() > fpos.getStartIndex()) { System.out.println(fpos.getStartIndex()); result.populateFieldPosition(fpos); }

This would be cheaper than allocating the FieldPositionIterator.

To be clear, this suggestion applies only to the new API that is still @draft, not to any of the old APIs.



Shane Carr


Shane Carr


Fix versions