سؤال

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.

هل كانت مفيدة؟

المحلول

Using String.replaceAll:

String abc = value.replaceAll("[^0-9.]", "");
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top