I'm using the following way, but it does not work because of the compiler for using things from javax.swing.text.DefaultFormatter.
public string formatar(String text, String mask) throws ParseException {
return new MaskFormatter(mask).valueToString(text);
}
I could not find a solution in the documentation available