As David Wallace said, you did not do this (or if you do, you do it very carefully and only if you are deeply informed about the problems), because double usually not suitable for use with currency values. It has issues like 0.1 + 0.2 ending in 0.30000000000000004 (and others). Used correctly , BigDecimal is probably better suited, although much slower. (More on how to "use it right" below.)
First, you must determine that thousands and decimal separators are used, from the locale ( see Boris for an excellent answer for this) or the information is provided along with the string. In some cultures, they , (thousand) And . (decimal), for example. "1,000.24", but in other cultures it is the other way around (for example, "1.000, 24"). As far as I know, in some places other symbols are used. (You cannot guess this from the line; you do not know if "1,234" means one thousand two hundred thirty-four or one point two three four.)
Once you know what it is, you want to remove the thousands separators, convert the decimal place to . (in particular), and then remove from the line all non-digital, non-minus, non-decimal numbers:
// where `currencyString` is the string containing the currency currencyString = currencyString .replace(thousandsString, "") .replace(decimalString, ".") .replaceAll("[^\\d.-]", "");
Then create your BigDecimal :
BigDecimal currency = new BigDecimal(currencyString);
... and set the scaling and rounding mode to suit your program. Also be sure to carefully read the Javadoc for various working methods. For example, as Peter Laurie noted in the comments, naive use of BigDecimal will give you runtime exceptions:
BigDecimal bd = new BigDecimal(43); bd = bd.divide(new BigDecimal(7));
You can handle them by providing rounding information:
BigDecimal bd = new BigDecimal(43); bd = bd.divide(new BigDecimal(7), RoundingMode.HALF_UP);
... but again, be sure to set the scale to what you are doing. For example, if your scale is 2 , then (43 / 7) * 7 RoundingMode.HALF_UP (43 / 7) * 7 with RoundingMode.HALF_UP will be 42.98 instead of 43 . Separation is especially difficult, you may need a significant scale, and then final rounding off to more normal currency level scales (usually 2, but sometimes you may need more seats on the right).
If you really really want a double , use Double.parseDouble :
// where `currencyString` is the string containing the currency currencyString = currencyString .replace(thousandsString, "") .replace(decimalString, ".") .replaceAll("[^\\d.-]", ""); double thisWillHaveIssues = Double.parseDouble(currencyString);