I have a variable of type double, I need to print it in upto 3 decimals of precision but it shouldn't have any trailing zeros...
eg. I need
2.5 // not 2.500 2 // not 2.000 1.375 // exactly till 3 decimals 2.12 // not 2.120 I tried using DecimalFormatter, Am i doing it wrong?
DecimalFormat myFormatter = new DecimalFormat("0.000"); myFormatter.setDecimalSeparatorAlwaysShown(false); Thanks. :)