人民币示意:数字转中文

人民币表示:数字转中文
import java.math.*;

public class RenMinBi {

   /**
   * @param args add by sujun ,May 17, 2011
   */
  private static final char[] data = new char[]{
   '零','壹','贰','叁','肆','伍','陆','柒','捌','玖'
  }; 
  private static final char[] units = new char[]{
  '拾','佰','仟','万','拾','佰','仟','亿'
  };

  public static String convert(BigInteger money)
  {
    StringBuffer sbf = new StringBuffer();
    int unit = 0;
    int index=0;
   
    System.out.println(money.toString());
    while(money!=BigInteger.ZERO){  
     if(unit==8)
     unit=0;
     int n =(money.mod(BigInteger.TEN)).intValue();
     if(index++!=0)  //不是第一位数字
     { 
       //如果该位数字不是0或者该位数字单位是万或者是亿,都在字符串中加入单位
       if(n!=0 || unit==3||unit==7)
       sbf.insert(0,units[unit++]);
       else
       unit++;//其余情况不将单位加入字符串
     }
      
     
       //如果该位数字为0且该位为第一位数字或者单位是万或者亿
		   if(n==0&&(index==1||unit==4||unit==8))
		   ;
	     else
       sbf.insert(0, data[n]);//加入中文数值表示
       money=money.divide(BigInteger.TEN);
       System.out.println(money.toString());
    }

    sbf.append("圆整");
    return modify(sbf);
   
    
  }
	
	
	
    public static String modify(StringBuffer s){
    String sb=s.toString();
		
    while(sb.indexOf("零零")!=-1)
    sb=sb.replaceAll("零零","零");
    sb=sb.replaceAll("零万","万").replaceAll("零亿","亿");
		
    return sb;
	
    }

    public static void main(String[] args) {
    System.out.println(convert(new BigInteger("900000000006891230")));
    }

}


运行结果如下图所示:
人民币示意:数字转中文