Groovy web console

subscribe to the feed Subscribe
to this
site

Adding commas in amount

Published 3 months ago by Mak with tags amount comma numbersystem format
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
Integer amount = 1000000;
Integer temp = amount;
String tempFormatted= '';
while(temp>=1000)
{
temp = temp/1000;
tempFormatted= tempFormatted.concat(",000");
}
String formatted= temp as String
formatted = formatted.concat(tempFormatted);
println formatted