import javax.swing.text.MaskFormatter;
public class ExempleMaskFormat {
public static void main(String args[]) throws Exception {
MaskFormatter mf = new MaskFormatter("A-AAAA-AAAA-A");
mf.setValueContainsLiteralCharacters(false);
System.out.println(mf.valueToString("123123123123"));
}
}