Summary
Make single quoting behavior within a java.text.ChoiceFormat String pattern apparent.
Problem
The other Format classes that take a String pattern such as DecimalFormat, CompactNumberFormat, and MessageFormat all provide specification on single quote behavior within a String pattern. ChoiceFormat does not have similar specification. This limits end users from not knowing how to use a Relation symbol and literal single quotes within a Format pattern.
Solution
Provide a small update at the bottom of the pattern section which describes the behavior that single quotes escape the meaning of a Relation symbol, and also how to use a literal single quote within a pattern.
Specification
Update the Patterns section with
--- a/src/java.base/share/classes/java/text/ChoiceFormat.java
+++ b/src/java.base/share/classes/java/text/ChoiceFormat.java
@@ -187,6 +187,12 @@
*
* <i>Note:The relation ≤ is not equivalent to <=</i>
*
+ * <p>If a <i>Relation</i> symbol is to be used within a <i>Format</i> pattern,
+ * it must be single quoted. For example,
+ * {@code new ChoiceFormat("1# '#'1 ").format(1)} returns {@code " #1 "}.
+ * Use two single quotes in a row to produce a literal single quote. For example,
+ * {@code new ChoiceFormat("1# ''one'' ").format(1)} returns {@code " 'one' "}.
+ *
- csr of
-
JDK-8315064 j.text.ChoiceFormat provides no specification on quoting behavior
-
- Resolved
-