Top "Decimalformat" questions

The Java class DecimalFormat is a concrete subclass of NumberFormat that is used to format decimal numbers.

How can I truncate a double to only two decimal places in Java?

For example I have the variable 3.545555555, which I would want to truncate to just 3.54.

java double truncate decimalformat
How to change the decimal separator of DecimalFormat from comma to dot/point?

I have this little crazy method that converts BigDecimal values into nice and readable Strings. private String formatBigDecimal(BigDecimal bd){ …

java android bigdecimal decimal-point decimalformat
How can I parse a String to BigDecimal?

I have this String: 10,692,467,440,017.120 (it's an amount). I want to parse it to a BigDecimal. The problem is that I …

java string parsing bigdecimal decimalformat
Laravel validate decimal 0-99.99

Laravel does not have a validation for decimal, so I need a regex or other validation method to validate a …

regex validation laravel-5 decimalformat
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().…

java formatting decimalformat
Formatting numbers using DecimalFormat

I am trying to format prices using DecimalFormat, but this isn't working for all variations. DecimalFormat df = new DecimalFormat("0.##") df.…

java decimalformat
How to use Java's DecimalFormat for "smart" currency formatting?

I'd like to use Java's DecimalFormat to format doubles like so: #1 - 100 -> $100 #2 - 100.5 -> $100.50 #3 - 100.41 -> $100.41 …

java formatting decimalformat
Java - Decimal Format.parse to return double value with specified number of decimal places

I want to be able to convert a string to a Double given a number of decimal places in a …

java parsing decimal rounding decimalformat
set double format with 2 decimal places

I have a short equation: double compute,computed2; compute=getminutes/60; where getminutes is int and I want to set the …

java swing int decimal decimalformat
DecimalFormat and Double.valueOf()

I'm trying to get rid of unnecessary symbols after decimal seperator of my double value. I'm doing it this way: …

java number-formatting decimalformat