I\'m trying to get rid of unnecessary symbols after decimal seperator of my double value. I\'m doing it this way:
DecimalFormat format = new DecimalFormat(\"
The fact that your formatting string uses . as the decimal separator while the exception complains of , points to a Locale issue; i.e. DecimalFormat is using a different Locale to format the number than Double.valueOf expects.
In general, you should construct a NumberFormat based on a specific Locale.
Locale myLocale = ...;
NumberFormat f = NumberFormat.getInstance(myLocale);
From the JavaDocs of DecimalFormat:
To obtain a NumberFormat for a specific locale, including the default locale, call one of NumberFormat's factory methods, such as getInstance(). In general, do not call the DecimalFormat constructors directly, since the NumberFormat factory methods may return subclasses other than DecimalFormat.
However as BalusC points out, attempting to format a double as a String and then parse the String back to the double is a pretty bad code smell. I would suspect that you are dealing with issues where you expect a fixed-precision decimal number (such as a monetary amount) but are running into issues because double is a floating point number, which means that many values (such as 0.1) cannot be expressed precisely as a double/float. If this is the case, the correct way to handle a fixed-precision decimal number is to use a BigDecimal.