Use a fixed NumberFormat
(specifically a DecimalFormat
):
double value = getValue();
String str = new DecimalFormat("#").format(value);
alternatively simply cast to int
(or long
if the range of values it too big):
String str = String.valueOf((long) value);
But then again: why do you have an integer value (i.e. a “whole” number) in a double
variable in the first place?