I currently use the following code to print a double: return String.format(“%.2f”, someDouble); This works well, except that Java uses my Locale’s decimal separator (a comma) while I would like to …
Tag: formatting
How to print formatted BigDecimal values?
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 BigDecimal and then using NumberFormat to make two-digit precision for the fraction part). Answer It will use
Show padding zeros using DecimalFormat
I’m using DecimalFormat to format doubles to 2 decimal places like this: DecimalFormat dec = new DecimalFormat(“#.##”); double rawPercent = ( (double)(count.getCount().intValue()) / …