[ Back | Previous | Next ]

How to create leading zeros with DecimalFormat?

Package:
java.text.*
Product:
JDK
Release:
1.0.2
Related Links:
DateFormat
DecimalFormat
NumberFormat
SimpleDateFormat
Comment:

public String getCreditAmountFormat() {
     DecimalFormat df = new DecimalFormat("00000000000000,000");
     df.setMinimumIntegerDigits(14);
     df.setMinimumFractionDigits(3);
     df.setGroupingUsed(false);
     DecimalFormatSymbols dfs = new DecimalFormatSymbols();
     dfs.setDecimalSeparator(',');
     df.setDecimalFormatSymbols(dfs);
     return df.format(creditAmount.doubleValue());
}
1