Ir para conteúdo

Format Money


flowzera

Posts Recomendados

public static String format(double value) {
        DecimalFormat decimalFormat = new DecimalFormat("#,###", new DecimalFormatSymbols(new Locale("pt", "BR")));
        return decimalFormat.format(value);
    }

    public static String getFormat(double value) {
        String[] simbols = new String[] { "", "K", "M", "B", "T", "Q", "QI", "S", "SEP", "OC", "N", "DEC", "UN", "DUO",
                "TRE" };
        int index;
        for (index = 0; value / 1000.0 >= 1.0; value /= 1000.0, ++index) {
        }
        return VariaveisAPI.format(value) + simbols[index];
    }

Link para o comentário
Compartilhar em outros sites

  • private static String formats[] = {"-", "-", "K", "M", "B", "T", "Q", "QT", "S", "ST", "QR"};
    public String format(Object value){
            String val = new DecimalFormat("#,###").format(value).replace(".", ",");
            Integer ii = val.indexOf(","), i = val.split(",").length;
            if(ii == -1)return val;
            return (val.substring(0, ii+2)+formats[i]).replace(",0", "");
        }

     

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...