Configuração de formatação de numeros no TomCat

3 respostas
M

Boa tarde,

Estou com uma situação que não consigo resolver, tenho o tomcat que uso na minha maquina para desenvolver e testar a aplicação e tenho um tomcat no servidor que executa a aplicação já em produção.
Na minha maquina funciona corretamente, porém no servidor dá um erro que acredito ser o formato dos números.

Esse é o erro que retorna:

java.lang.NumberFormatException: multiple points
	at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
	at sun.misc.FloatingDecimal.parseDouble(Unknown Source)
	at java.lang.Double.parseDouble(Unknown Source)
	at br.com.bravox.fluxocaixaweb.InicialBean.postExport(InicialBean.java:793)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

Por isso acredito que o problema seja na formatação do numero no servidor.

Alguém saberia uma forma de solucionar isso? Não entendo nada de Tomcat e estou com grande dificuldade em achar uma solução.

Obrigado.

3 Respostas

staroski

Qual o parâmetro que você está passando pro método postExport?

M
Boa tarde, segue o código. Obrigado.   

     Workbook workbook = (Workbook) document;

            //CellStyle cellStyle = workbook.createCellStyle();
            CreationHelper createHelper = workbook.getCreationHelper();
            // cellStyle.setDataFormat(createHelper.createDataFormat().getFormat("dd/MM/yyyy"));

            for (int i = 1; i < workbook.getSheetAt(0).getPhysicalNumberOfRows(); i++) {
                try {
                    for (int x = 0; x < 3; x++) {
                        Cell currentCell = workbook.getSheetAt(0).getRow(i).getCell(7 + x);
                        String s = currentCell.getStringCellValue();
                        s = s.replace("R$", "").replace("$", "").replace(".", "").replace(" ", "").replace(")", "").replace("(", "-");
                        if (s.endsWith(",")) {
                            s = s.replace(",", "");
                        }
                        
                        s = s.replace(",", ".");
                        currentCell.setCellValue(Double.parseDouble(s.trim()));
                        currentCell.setCellType(CellType.NUMERIC);
                    }
                    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
                    Cell currentCell = workbook.getSheetAt(0).getRow(i).getCell(5);
                    currentCell.setCellValue(format.parse(currentCell.getStringCellValue()));
                    //currentCell.setCellStyle(cellStyle);
                    CellUtil.setCellStyleProperty(currentCell, CellUtil.DATA_FORMAT, createHelper.createDataFormat().getFormat("dd/MM/yyyy"));
                } catch (ParseException ex) {
                    Logger.getLogger(InicialBean.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
staroski

Seu erro está acontecendo no método postExport da classe InicialBean.
Que valor você está passando pra esse método?

Criado 26 de junho de 2020
Ultima resposta 29 de jun. de 2020
Respostas 3
Participantes 2