Package 

Class ArithUtils


  • 
    public class ArithUtils
    
                        

    身份证号码、银行卡号、手机号格式化 精确的加减乘除运算

    • Method Summary

      Modifier and Type Method Description
      static String hintPhone(String str) 将手机号格式化为123****4123的形式
      static String hintIDCard(String str) 将身份证号格式化为1234 **** **** 1234
      static String hintBank(String str) 将银行卡号格式化为**** **** **** 4234的形式
      static String getBankEnding(String str) 获取银行卡的四位尾号
      static double add(double v1, double v2) 提供精确的加法运算。
      static double sub(double v1, double v2) 提供精确的减法运算。
      static double mul(double v1, double v2) 提供精确的乘法运算。
      static double div(double v1, double v2) 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到小数点以后10位,以后的数字四舍五入。
      static double div(double v1, double v2, int scale) 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指定精度,以后的数字四舍五入。
      static double round(double v, int scale) 提供精确的小数位四舍五入处理。
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • hintPhone

         static String hintPhone(String str)

        将手机号格式化为123****4123的形式

        Parameters:
        str - 字符串
      • hintIDCard

         static String hintIDCard(String str)

        将身份证号格式化为1234 **** **** 1234

        Parameters:
        str - 字符串
      • hintBank

         static String hintBank(String str)

        将银行卡号格式化为**** **** **** 4234的形式

        Parameters:
        str - 字符串
      • add

         static double add(double v1, double v2)

        提供精确的加法运算。

        Parameters:
        v1 - 被加数
        v2 - 加数
      • sub

         static double sub(double v1, double v2)

        提供精确的减法运算。

        Parameters:
        v1 - 被减数
        v2 - 减数
      • mul

         static double mul(double v1, double v2)

        提供精确的乘法运算。

        Parameters:
        v1 - 被乘数
        v2 - 乘数
      • div

         static double div(double v1, double v2)

        提供(相对)精确的除法运算,当发生除不尽的情况时,精确到小数点以后10位,以后的数字四舍五入。

        Parameters:
        v1 - 被除数
        v2 - 除数
      • div

         static double div(double v1, double v2, int scale)

        提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指定精度,以后的数字四舍五入。

        Parameters:
        v1 - 被除数
        v2 - 除数
        scale - 表示表示需要精确到小数点以后几位。
      • round

         static double round(double v, int scale)

        提供精确的小数位四舍五入处理。

        Parameters:
        v - 需要四舍五入的数字
        scale - 小数点后保留几位