Package javax.swing.text

Examples of javax.swing.text.MaskFormatter.valueToString()


   
    //Dentro do bloco try.. catch.. tentaremos adicionar uma mascara ao nosso CPF
         try{
        MaskFormatter mf = new MaskFormatter("###.###.###-##")
        mf.setValueContainsLiteralCharacters(false);
        cpf = mf.valueToString(texto);
         }catch(Exception ex){
           ex.printStackTrace();
         }
   
    return cpf; 
View Full Code Here


    String m = this.getMask();
    if( !StringUtils.isEmpty( pv ) && m != null) {
      try {
        MaskFormatter mf = new MaskFormatter(m);
        mf.setValueContainsLiteralCharacters(false);
        maskedValue = mf.valueToString(pv);
        if(maskedValue != null) {
          // MaskFormatter leaves extra white space if it's too short, not good
          // for our purposes
          maskedValue = maskedValue.trim();
        }
View Full Code Here

  public String formatar(Object valor, String mascara) {
    try {
      MaskFormatter formatter = new MaskFormatter(mascara);
      formatter.setValueContainsLiteralCharacters(false);
      valor = formatter.valueToString(valor);
    } catch (ParseException e) {
      log.info(e.getMessage());
    }
    return valor.toString();
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.