/** * @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); }