Double amount = 0.001
but amount value is set to 0.0010
we have strict condition at the end to allow only 3 decimal places before storing in DB. but somehow it is appending 0 at the end.
i have tried
DecimalFormat decimalFormat = new DecimalFormat("#.###");
String formatedString = decimalFormat.format(amount));
at this point formatedString
in 0.001 which is correct. but if i change back again to Double.
Double.valueOf(decimalFormat.format(formatedString));
it is again adding 0 at the end 0.0010. how to remove 0 at the end by default for type Double?