NumberFormatException in String.Format("%05.2f", 8.00)

Viewed 1392

I'm using italian locale for my program so Float.parseFloat("8,00") must function well. But I have encountered a very bad NFE in the following line:

this.cuSurfaceJTextField1.setValue(
    String.format("%05.2f",info.getCuSurface()));

I note that the above code used to work well up to some changes I made to the listeners that don't look to be related to this line of the code.(Now I have a propertyChangeListener that updates the model when the value is changed.

this.cuSurfaceJTextField1.addPropertyChangeListener("value", 
        new PropertyChangeListener() {

    @Override
    public void propertyChange(PropertyChangeEvent evt) {
        info.setCuSurface(Float.parseFloat(
                (String)cuSurfaceJTextField1.getValue()));
        updateCuSurface();
    }
});

The useful part of the exception:

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "08,00"
    at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1241)
    at java.lang.Float.parseFloat(Float.java:452)
    at View.bars.QuadrateJPanel$11.propertyChange(QuadrateJPanel.java:348)
    at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:328)
    at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
    at java.awt.Component.firePropertyChange(Component.java:8382)
    at javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:799)
    at javax.swing.JFormattedTextField.setValue(JFormattedTextField.java:502)
3 Answers
Related