NumberUtils新增formatNumber方法
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
package com.jeesite.common.lang;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
* BigDecimal工具类
|
||||
@@ -92,4 +93,19 @@ public class NumberUtils extends org.apache.commons.lang3.math.NumberUtils {
|
||||
return bg.setScale(0, BigDecimal.ROUND_HALF_UP).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化数值类型
|
||||
* @param data
|
||||
* @param pattern
|
||||
*/
|
||||
public static String formatNumber(Object data, String pattern) {
|
||||
DecimalFormat df = null;
|
||||
if (pattern == null) {
|
||||
df = new DecimalFormat();
|
||||
} else {
|
||||
df = new DecimalFormat(pattern);
|
||||
}
|
||||
return df.format(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user