Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android String format - price

Tags:

android

Is there an easy formatter to format my String as a price?

So my string is: 300000 i'd like to "300 000" with space

or 1000000 "1 000 000"

Leslie

like image 602
lacas Avatar asked Jul 14 '11 08:07

lacas


2 Answers

This does it:

String s = (String.format("%,d", 1000000)).replace(',', ' ');
like image 131
Caner Avatar answered Oct 21 '22 13:10

Caner


Use Formatter class to format string

format("%,d", 1024);

After that replace , with space.

http://developer.android.com/reference/java/util/Formatter.html

like image 24
Ketan Parmar Avatar answered Oct 21 '22 12:10

Ketan Parmar