Format Double with two house

0

I am dealing with a .csv file with an id , value (1,214.45) and need to format a final sum of these values with only two boxes after the comma. p>

Developed the following code snippet:

'DecimalFormat df = new DecimalFormat("0.##");
    for(Integer i : filiais) {
        Double soma = 0.0;
        int contador = 0;
        for(String s : list) {
            String[] arr = new String[2];
            arr = s.split(",");
            if (arr[0].equals(i.toString())) {
                soma += Double.parseDouble(arr[1]);
                contador++;
            }
        }
        String aux = df.format(soma);
        somaFiliais.add(Double.parseDouble(aux));
        contadorFiliais.add(contador);
    }'

I have the following error:

Exception in thread "main" java.lang.NumberFormatException: For input string: "53010,77"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
    at java.lang.Double.parseDouble(Double.java:538)
    at Exercicio1.gerarRelatorio(Exercicio1.java:57)
    at Exercicio1.main(Exercicio1.java:26)
    
asked by anonymous 18.04.2018 / 07:14

0 answers