The reason for collecting this question is that I have done it before, but it is very troublesome to implement it. This time, it is easy to understand what others wrote.
We can see from a PDF that the source is not pasted =. =
Public class Renmingbi {Private Static final char [] DATA = new char [] {'0', 'yi', 'er', 'san', 'Ta ', 'wo', 'loan', 'region'}; Private Static final char [] Units = new char [] {'meta ', 'pick', 'handler', 'handler', 'wan', 'handler ', 'clerk'}; // simple integer INT:-2147483648 ~ 2147483647 public static string convert (long money) {stringbuffer SBF = new stringbuffer (40); int unit = 0; while (money! = 0) {SBF. insert (0, units [unit ++]); int number = (INT) Money % 10; SBF. insert (0, data [number]); money/= 10;} // system. out. println (SBF. tostring (); Return SBF. tostring (). replaceall ("Zero [zhibai]", "zero "). replaceall ("0 + 1 million", "1 million "). replaceall ("Zero + ten thousand", "Ten Thousand "). replaceall ("Zero + RMB", "RMB "). replaceall ("Zero +", "zero "). replaceall ("", "");} // complex long with decimals:-2 ^ 63 + 2 ^ 63-1 public static string convert (double value) {long midval = (long) (value * 100); string valstr = string. valueof (midval); // convert it to string rail = valstr. substring (valstr. length ()-2); // take the decimal part long preint = (midval/100); string prefix = convert (preint); string suffix = ""; // process the number of decimal places if (rail. equals ("00") {suffix = "whole";} else {suffix = data [rail. charat (0)-'0'] + "" + data [rail. charat (1)-'0'] + "points";} return prefix + suffix; // return the correct representation} public static void main (string [] ARGs) {system. out. println (convert (2000000007); system. out. println (convert (2000000007.211 ));}}
Pen: amount conversion, the amount of Arabic numerals is converted into a traditional Chinese form, such as: (¥1011)-> (one thousand and one pick up one yuan) Output