---
title: "文字列转换成数字形式"
author: "hecal"
date: "2009-09-21T11:13:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2011-12-07T18:09:31Z"
id: 1296499
url: "https://hecal.iteye.com/blog/1296499"
---

/\**  
\* 数字文字列形式変換  
\* @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 &gt; 3) {  
strBffer.insert((numLenth - 3), ",");  
numLenth -= 3;  
}

num = strBffer.toString();

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

return num;  
}