mardi 21 avril 2015

Format a double without decimals & adding commas for thousands in Scala Java Play framework

I have doubles such as:

87654783927493.00

23648.00

I want to output them as:

87,654,783,927,493

23,648


I found the following solution:

@("%,.2f".format(myDoubleHere).replace(".00",""))

This was with the help of:

how to format a number/date in play 2.0 template?

What is the proper way to format a double in a Play 2 template


I'd like to replace this shameless solution by something more clean. Chopping off those decimals using a .replace() method is really not pretty.

Aucun commentaire:

Enregistrer un commentaire