始终保留两位小数
parent
b00bac8295
commit
7c3247e934
|
@ -48,18 +48,17 @@ public class Utils {
|
|||
|
||||
|
||||
/**
|
||||
* 小数则保留两位小数
|
||||
* 整数就是整数
|
||||
* 保留两位小数
|
||||
*/
|
||||
public static String format(Number number, String defaultValue){
|
||||
if (null == number) {
|
||||
return defaultValue;
|
||||
}else {
|
||||
return new java.text.DecimalFormat("#0.##").format(number);
|
||||
return new java.text.DecimalFormat("#0.00").format(number);
|
||||
}
|
||||
}
|
||||
public static String format(Number number){
|
||||
return format(number, "");
|
||||
return format(number, "0.00");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue