Java Swing Text Format formata(String s, String mascara)

Here you can find the source of formata(String s, String mascara)

Description

formata

License

Open Source License

Declaration

public static String formata(String s, String mascara) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.text.ParseException;

import javax.swing.text.MaskFormatter;

public class Main {

    public static String formata(String s, String mascara) {
        MaskFormatter formatter;// w ww .  jav  a  2s .c  o  m
        try {
            formatter = new MaskFormatter(mascara);
            formatter.setValueContainsLiteralCharacters(false);
            return formatter.valueToString(s);
        } catch (ParseException e) {
            return s;
        }
    }
}

Related

  1. findElementUp(String name, Element start)
  2. findMatchingBracket(Element el, int offset)
  3. findNext(boolean reverse, int pos)
  4. formartCpf(String cpf)
  5. format(String pattern, Object value)
  6. formatAreaImperial(BigDecimal areaDec)
  7. formatAreaMetric(BigDecimal area)
  8. formatCEP(String str)
  9. formatCpfCnpj(String cpfCnpj)