String NumberFormat :
NumberFormat formatter = new DecimalFormat("0000000");
This means your string will be filled with zeros as you want.
And then, to get the string format, you can do:
String formatRes = formatter.format(new Double(val));
because the "format" method requires a double argument.
source
share