Insert commas into integers

Is there an easy way in Android to insert commas into a numeric value? those. if I have an EditText with 12345 in it, how can I display this as 12.345?

I think I can do this with a substring and chop it into x number from 3 rows of numbers, and then concatenate the answer with "," between every three numbers. It would be quite easy if the length of the number were constant, but since the number could be from one digit to, say, 20, this makes it more complicated.

It's just curious if there is a simple and clean way to achieve this before I start making my subscript decision.

Greetings

+5
source share
1

Java -

- :

    double amount = 2324343192.015;
    NumberFormat formatter = new DecimalFormat("###,###,###.##");
    System.out.println("The Decimal Value is: "+formatter.format(amount));

: : 2,324,343,192.02

+16

All Articles