现在的位置: 首页 > 综合 > 正文

java中格式化数字

2018年02月04日 ⁄ 综合 ⁄ 共 223字 ⁄ 字号 评论关闭

public static String formatNumber(double number) {
String res = "";
DecimalFormat numberDf = new DecimalFormat();
try {
numberDf.applyPattern("0000");
res = numberDf.format(number);
} catch (Exception e) {
e.printStackTrace();
res = "0001";
}
return res;
}

抱歉!评论已关闭.