1

I have a value of 100000

What I get 100,000

What I want 100, 000

I am supporting API 15.

I format it as indonesian currency using

new StringBuilder("Rp. ").append(String.format("%,d", parseInt(amount[position])));

What I've tried

String.format("%1s", String.format("%,d", parseInt(amount[position])));

I came from Web Dev world and I find Java android so difficult.

hdotluna
  • 5,514
  • 4
  • 20
  • 31

2 Answers2

0

Provided you have a String :

String x = "100,000";

Then you can use replaceAll() to generate 100,000 -> 100, 000

Eg:

    String x = "100,000";

    System.out.println(x.replaceAll(",",", "));

Which shall print 100, 000

OBX
  • 6,044
  • 7
  • 33
  • 77
0

For Currency formatting best approach is to use Locale read more here.

Locale locale= // build your locale here
String value= NumberFormat.getCurrencyInstance(locale).format(100000)
Nayan Srivastava
  • 3,655
  • 3
  • 27
  • 49