Funtime
·
Mar 16, 2011
·
Viewed 168.3k times
·
Source
How to set thousands separator in Java?
I have String representation of a BigDecimal that I want to format with a thousands separator and return as String.
I have a BigDecimal field amount which represents money, and I need to print its value in the browser in a format like $123.00, $15.50, $0.33.
How can I do that?
(The only simple solution which I see myself is getting floatValue from …
How could I convert from float to string or string to float?
In my case I need to make the assertion between 2 values string (value that I have got from table) and float value that I have calculated.
String valueFromTable = "25";
…
Is there a way to format a decimal as following:
100 -> "100"
100.1 -> "100.10"
If it is a round number, omit the decimal part. Otherwise format with two decimal places.