Frage

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.

War es hilfreich?

Lösung

Using String.replaceAll:

String abc = value.replaceAll("[^0-9.]", "");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top