Detailed code procedure


    /** * <b> <br> *@author newzhong
    * @sinceJDK 1.8 * * /
   public String financialFormatStr(BigDecimal num){
  
        // Initialize to 0.00
        StringBuilder result = new StringBuilder("0.00");
        
        String errFormat = 00 ".";
        String point = ".";
        
        // Determine whether the value passed is null or 0
        if(num ! =null || num.equals(BigDecimal.ZERO)){
        
            // format Financial format
            DecimalFormat decimalFormat = new DecimalFormat("# # #, # # 0.00");
            String format = decimalFormat.format(num);
            
            // Special case judgment
            if (errFormat.equals(format)){
                format = "0.00";
            }
            if (point.equals(format)){
                format = "0" + format;
            }
            return format;

        }else {
            returnresult.toString(); }}/** * <b> <br> *@author newzhong
    * @sinceJDK 1.8 * * /
    public BigDecimal financialToNum(String moneyStr){
        String moneyNum = moneyStr.replaceAll(","."");
        BigDecimal bigDecimal = new BigDecimal(moneyNum);
        return bigDecimal;
    }
Copy the code