Note the comma in your string: "1,07". DecimalFormat
uses a locale-specific separator string, while Double.parseDouble()
does not. As you happen to live in a country where the decimal separator is ",", you can't parse your number back.
However, you can use the same DecimalFormat
to parse it back:
DecimalFormat df=new DecimalFormat("0.00");
String formate = df.format(value);
double finalValue = (Double)df.parse(formate) ;
But you really should do this instead:
double finalValue = Math.round( value * 100.0 ) / 100.0;
Note: As has been pointed out, you should only use floating point if you don't need a precise control over accuracy. (Financial calculations being the main example of when not to use them.)