|
|
@@ -43,6 +43,26 @@ public class FormatNumUtil {
|
|
|
|
|
|
|
|
|
/**
|
|
|
+ * @method formatNumberWithDot
|
|
|
+ * @description 保留一位小数
|
|
|
+ * @date: 2020/4/17 8:36
|
|
|
+ * @author: 牛松涛
|
|
|
+ * @param string
|
|
|
+ * @return java.lang.String
|
|
|
+ */
|
|
|
+ public static String formatNumberOneDecimal(String string){
|
|
|
+ string = scientificNotation(string);//科学计数法转换
|
|
|
+ DecimalFormat df1 = new DecimalFormat("#.#");
|
|
|
+ try {
|
|
|
+ return df1.format(new BigDecimal(string));
|
|
|
+ } catch (Exception e){
|
|
|
+ return string;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
* @method phoneAddStar
|
|
|
* @description 手机号码脱敏处理
|
|
|
* @date: 2020/4/26 14:28
|
|
|
@@ -100,4 +120,21 @@ public class FormatNumUtil {
|
|
|
}
|
|
|
return longNum;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @method getThousandNum
|
|
|
+ * @description 千化(1000 转化 1K)
|
|
|
+ * @date: 2020/9/30 15:25
|
|
|
+ * @author: niusongtao
|
|
|
+ * @param num
|
|
|
+ * @return java.lang.String
|
|
|
+ */
|
|
|
+ public static String getThousandNum(double num){
|
|
|
+ if (num >= 0 && num < 1000)
|
|
|
+ return formatNumberOneDecimal(num + "");
|
|
|
+ else{
|
|
|
+ return formatNumberOneDecimal(num/1000 + "") + "K";
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|