java.text.ChoiceFormat provides the ability to quote values within the String pattern but does not make it apparent or explain the behavior in the API docs.
For example,
var cf = new ChoiceFormat(" 1#'example' ");
var otherCf = new ChoiceFormat(" 1#example ");
cf.format(1) == otherCf.format(1); // returns true
or
var cf = new ChoiceFormat(" 1#'#' "); // works
var cf = new ChoiceFormat(" 1## "); // throws an exception
The single quotes can be used to escape the values of "#", "<", "≤" and "|" which are usually recognized as special characters by ChoiceFormat otherwise. The other Format classes such as Decimal, CompactNumber, and Message all provide specification on single quotes within a pattern; choiceFormat should as well.
For example,
var cf = new ChoiceFormat(" 1#'example' ");
var otherCf = new ChoiceFormat(" 1#example ");
cf.format(1) == otherCf.format(1); // returns true
or
var cf = new ChoiceFormat(" 1#'#' "); // works
var cf = new ChoiceFormat(" 1## "); // throws an exception
The single quotes can be used to escape the values of "#", "<", "≤" and "|" which are usually recognized as special characters by ChoiceFormat otherwise. The other Format classes such as Decimal, CompactNumber, and Message all provide specification on single quotes within a pattern; choiceFormat should as well.
- csr for
-
JDK-8317282 j.text.ChoiceFormat provides no specification on quoting behavior
-
- Closed
-