How to remove decimal values from a value of type 'double' in Java

Nice and simple. Add this snippet in whatever you're outputting to:

String.format("%.0f", percentageValue)

You can convert the double value into a int value. int x = (int) y where y is your double variable. Then, printing x does not give decimal places (15000 instead of 15000.0).


I did this to remove the decimal places from the double value

new DecimalFormat("#").format(100.0);

The output of the above is

100


You could use

String newValue = Integer.toString((int)percentageValue);

Or

String newValue = Double.toString(Math.floor(percentageValue));