The following five solutions are proposed from CSDN:
1. (JAVA)
Public static String numtochinese (String input ){
String s1 = "";
String s4 = "getting hundreds of millions of users and hundreds of millions of users in different regions ";
String temp = "";
String result = "";
If (input = null) return "the input string is not a numeric string and can only contain the following characters ('0 ′~ '9', '.'), the maximum input string can be precise to hundreds of millions, only two decimal places! ";
Temp = input. trim ();
Float f;
Try {
F = Float. parseFloat (temp );
} Catch (Exception e) {return "the input string is not a numeric string and can only contain the following characters ('0 ′~ '9', '.'), the maximum input string can be precise to hundreds of millions, only two decimal places! ";}
Int len = 0;
If (temp. indexOf (".") =-1) len = temp. length ();
Else len = temp. indexOf (".");
If (len> s4.length ()-3) return ("the maximum input string can be accurate to million, and only two decimal places can be entered! ");
Int n1, n2 = 0;
String num = "";
String unit = "";
For (int I = 0; I If (I> len + 2) {break ;}
If (I = len) {continue ;}
N1 = Integer. parseInt (String. valueOf (temp. charAt (I )));
Num = s1.substring (n1, n1 + 1 );
N1 = len-I + 2;
Unit = s4.substring (n1, n1 + 1 );
Result = result. concat (num). concat (unit );
}
If (len = temp. length () | (len = temp. length ()-1) result = result. concat ("whole ");
If (len = temp. length ()-2) result = result. concat ("0 ");
Return result;
}
2. (JSP)