java double keep 2 decimal only code example Example: java double 2 decimal String result = String.format("%.2f", value);