Classe ‘Formatter’ et ‘MaskFormatter’: Comment appliquer un format spécial (Monétaire, téléphonique, etc) à des données

Author:


{filelink=5783}


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"));
  }
}

Leave a Reply

Your email address will not be published. Required fields are marked *