关于大小写转换器的问题 我到是写了一个普通的java金额大小写转换的程序,swing不太会,程序也太长~ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我这有直接转成string的,你可以参考一下/** * translante an int to 人民币大写形式 * @param int money , money want to translate * @return String[] the return array . 从"分" 到 "亿" */ public static String[] moneyToRMB(long money) { String[] returnStr = { "", "", "", "", "", "", "", "", "", ""}; int i, j, index; long mod, result; String[] RMB = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; for (i = 0; i < 10; i++) { try { byte[] byteTmp = RMB[i].getBytes("GB2312"); RMB[i] = new String(byteTmp, "8859_1"); } catch (Exception e) { System.out.println(" CommonUtil.java.moneyToRMB() error" + e.toString()); e.printStackTrace(); } } for (i = 0; i < 10; i++) { mod = 1; for (j = 0; j < (9 - i); j++) mod = mod * 10; result = money / mod; Long tmp = new Long(result); index = tmp.intValue(); if (result == 0) { returnStr[9 - i] = RMB[0]; } else { try { returnStr[9 - i] = RMB[index]; money = money - mod * result; } catch (Exception e) { System.out.println(" CommonUtil.java.moneyToRMB() error" + e.toString()); e.printStackTrace(); } } } return returnStr; } 小问题请教,谢谢! 程序写不下去了,求高人帮忙 java循环中执行多线程问题-如何在循环中等待一个线程结束后再自动开始新的线程 求教,如何从文件中读取数据 请教一道面试题? 请问要如何在JDialog上绘制图形? 关于java中的url参数 在线等,急阿,散分!!!,高手来帮忙阿,谢谢 如何在ROSE生成java代码时自动生成import 语句? 怎么得到文件的创建时间? 如何在JAVA中显示图片 socket连接问题
/**
* translante an int to 人民币大写形式
* @param int money , money want to translate
* @return String[] the return array . 从"分" 到 "亿"
*/
public static String[] moneyToRMB(long money) {
String[] returnStr = {
"", "", "", "", "", "", "", "", "", ""};
int i, j, index;
long mod, result;
String[] RMB = {
"零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"}; for (i = 0; i < 10; i++) {
try {
byte[] byteTmp = RMB[i].getBytes("GB2312");
RMB[i] = new String(byteTmp, "8859_1");
}
catch (Exception e) {
System.out.println(" CommonUtil.java.moneyToRMB() error" +
e.toString());
e.printStackTrace();
}
} for (i = 0; i < 10; i++) {
mod = 1;
for (j = 0; j < (9 - i); j++)
mod = mod * 10; result = money / mod;
Long tmp = new Long(result);
index = tmp.intValue(); if (result == 0) {
returnStr[9 - i] = RMB[0];
}
else {
try {
returnStr[9 - i] = RMB[index];
money = money - mod * result;
}
catch (Exception e) {
System.out.println(" CommonUtil.java.moneyToRMB() error" +
e.toString());
e.printStackTrace();
}
}
} return returnStr;
}