package com.test;
import java.text.DecimalFormat;
public class FormatTest {
public static void main(String[] args) {
System.out.print(formatNum(5.0));
}
private static String formatNum(Double d) {
String formatPattern = "#,##0.000";
if (d == null) {
return "-";
} else {
if (d == 0) {
return "-";
}
return new DecimalFormat(formatPattern).format(d);
}
}
}