ITeye博客

文字列转换成数字形式

hecal · 2009-09-21 11:13 · Markdown

/**
* 数字文字列形式変換
* @param num 数字文字列
* @return 表示用数字文字列
*/
private static String toViewFugouSu(String num) {
if (num == null) {
return null;
}

String strFogou = "";
int numLenth = num.length();
if (num.substring(0,1).equals("-") || num.substring(0,1).equals("+")) {
strFogou = num.substring(0,1);
num = num.substring(1, numLenth);
numLenth = num.length();
}

StringBuilder strBffer = new StringBuilder(num);

while (numLenth > 3) {
strBffer.insert((numLenth - 3), ",");
numLenth -= 3;
}

num = strBffer.toString();

if (!"".equals(strFogou)) {
num = strFogou + num;
}

return num;
}

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。