On Mon, 6 Dec 2021 17:16:20 GMT, Phil Race <[email protected]> wrote:
>> src/java.desktop/share/classes/javax/swing/text/MaskFormatter.java line 103:
>>
>>> 101: * MaskFormatter formatter = new MaskFormatter("###-####");
>>> 102: * formatter.setPlaceholderCharacter('_');
>>> 103: * formatter.getDisplayValue(tf, "123");
>>
>> This code is part of an example, without this line, the following lines of
>> documentation do not make sense. Probably, `getDisplayValue` should be
>> replaced with `valueToString`. You should check that and ensure the sample
>> and the expected output, as discussed in the following sentences, is correct.
>
> I agree. Simply deleting this line solves nothing. The example needs to be
> reviewed and the text needs to say something correct and useful.
Yeah, I've checked with `valueToString` method, its working fine. I'll replace
`getDisplayValue` with `valueToString`? ValueToString takes one parameter which
is of Object type. It return the formated value.
Sample Code:
MaskFormatter formatter = new MaskFormatter("###-##");
formatter.setPlaceholderCharacter('*');
System.out.println(formatter.valueToString("87"));
Output:
87*-**
-------------
PR: https://git.openjdk.java.net/jdk/pull/6556