Question

I have a value £211,064.10 and i want to convert like 211064.10 and i tried the following way

String value = "$107,990.67";       

String abc = value.replace(NumberFormat.getCurrencyInstance().getCurrency().getSymbol(), "");       
System.out.println(abc);
System.out.println(abc.replace(",", ""));`

But it works only for the currency symbol $ not for any other currency value.

Was it helpful?

Solution

Using String.replaceAll:

String abc = value.replaceAll("[^0-9.]", "");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top