• 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);
        }
  • 相关阅读:
    16日彻底去除安卓应用的内置广告
    配台600元的主机套装 自己组装 全新
    带记录功能的计算器
    华为8812 进入工程模式 和打电话黑屏问题
    买平板 四核 500~600左右对比
    querySelector()方法
    Javascript实例教程:querySelector()方法接受一个CSS查询并返回匹配模式的第一个子孙元素,如果没有匹配的元素则返回null。
    Android实用代码七段(二)
    Android实用代码七段(三)
    Firebug入门指南
  • 原文地址:https://www.cnblogs.com/yy123/p/4244011.html
Copyright © 2020-2023  润新知