在java中,将阿拉伯数字转换成大写

package com;

public class ConvertNumber {

	private static final char[] data=new char[]{
		'零','壹','贰','叁','肆','伍','陆','柒','捌','玖'
	}; 
	private static final char[] info=new char[]{
		'元','拾','佰','仟','万','拾','佰','仟','亿'
	};
	
	public static void main(String[] args) {
		System.out.println(convert(1234567));
	}
	public static String convert(int money){
		StringBuffer bf=new StringBuffer();
		int i=0;
		while(money!=0){
			bf.insert(0, info[i++]);
			int number = money%10;   
			bf.insert(0, data[number]);   
			money /= 10; 
		}
		return bf.toString().replaceAll("零[拾佰仟万]","零").replaceAll("零+万","万").replaceAll("零+元","元").replaceAll("零+","零");  
		//return bf.toString();
	}
}


 

你可能感兴趣的:(Java)