• java切割~~百万 十万 万 千 百 十 个 角 分


     /**
         * @param value
         * @return
         */
        @SuppressWarnings("unused")
        public static void convertLoanRMBTable(double value) {
            LoanContractTemplateBean.LoanRMBTable loanRMBTable = new LoanContractTemplateBean.LoanRMBTable();
                    //百万          十万            万                千            百                十            个              角                分
            String million = "",lakh= "",tenThousand= "",thousand="",hundred= "",ten= "",one="",dime= "",cent= "";
            long midVal = (long) (((value+0.000001) * 1000) / 10); //转化成整形
            String valStr = String.valueOf(midVal); //转化成字符串
            //确保字符串长度大于等于2
            if (valStr.length() == 1) {
                valStr = "0" + valStr;
            }
            String head = valStr.substring(0, valStr.length() - 2);//取整数部分
            String rail = valStr.substring(valStr.length() - 2);//取小数部分
            int headLen = head.length();
            dime=rail.charAt(0) + "";
            cent=rail.charAt(1) + "";
            //9000000
            if (headLen < 7) {
                head = "¥" + head;
                int headLen2 = head.length();
                if (headLen2 < 7) {
                    String added = "";
                    for (int i = 0; i < 7 - headLen2; i++) {
                        added += "a";
                    }
                    head = added + head;
                }
                million= head.charAt(0) == 'a' ? "" : head.charAt(0) + "";
                lakh=head.charAt(1) == 'a' ? "" : head.charAt(1) + "";
                tenThousand=head.charAt(2) == 'a' ? "" : head.charAt(2) + "";
                thousand=head.charAt(3) == 'a' ? "" : head.charAt(3) + "";
                hundred=head.charAt(4) == 'a' ? "" : head.charAt(4) + "";
                ten=head.charAt(5) == 'a' ? "" : head.charAt(5) + "";
                one=head.charAt(6) == 'a' ? "" : head.charAt(6) + "";
            } else if (headLen == 7) {
                million= "¥" + head.charAt(0);
                lakh=head.charAt(1) + "";
                tenThousand=head.charAt(2) + "";
                thousand=head.charAt(3) + "";
                hundred=head.charAt(4) + "";
                ten=head.charAt(5) + "";
                one=head.charAt(6) + "";
            }
            System.out.println("百万==="+million+"	十万==="+lakh+"	万==="+tenThousand+"	千==="+thousand+"	百==="+hundred+"	十==="+ten+"	个==="+one+"	角===="+dime+"	分===="+cent);
        }
        //测试
        public static void main(String[] args) {
            convertLoanRMBTable(3225658.25);
        }
  • 相关阅读:
    [LeetCode] 314. Binary Tree Vertical Order Traversal
    [LeetCode] 139. Word Break
    [LeetCode] 540. Single Element in a Sorted Array
    [LeetCode] 1443. Minimum Time to Collect All Apples in a Tree
    [LeetCode] 1442. Count Triplets That Can Form Two Arrays of Equal XOR
    [LeetCode] 1441. Build an Array With Stack Operations
    [LeetCode] 277. Find the Celebrity
    [LeetCode] 1232. Check If It Is a Straight Line
    [LeetCode] 10. Regular Expression Matching
    [LeetCode] 1192. Critical Connections in a Network
  • 原文地址:https://www.cnblogs.com/yy123/p/4244011.html
Copyright © 2020-2023  润新知