/** 格式化价格**/
public static String formatPrice(Double price){
String result = "";
try {
DecimalFormat decimalFormat = new DecimalFormat("0.00");
result = decimalFormat.format(price);
}
catch (Exception e) {
}
return result;
}
public static String formatPrice(Double price){
String result = "";
try {
DecimalFormat decimalFormat = new DecimalFormat("0.00");
result = decimalFormat.format(price);
}
catch (Exception e) {
}
return result;
}
本文介绍了一个用于格式化价格的Java方法。该方法使用DecimalFormat类将Double类型的价格格式化为带有两位小数的标准字符串形式。此功能对于显示货币金额特别有用。

被折叠的 条评论
为什么被折叠?



