Java Double to String conversion without formatting

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?

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)