package com.sunboon.jiexi;
/** *
* @author qizhenglong
* */
public class moneyutil ;
/** 整數部分的單位 */
private static final string iunit = ;
/** 小數部分的單位 */
private static final string dunit = ;
/*** 得到大寫金額。
*/public static string tochinese(string str) else if (str.indexof(".") == 0) else
// integerstr去掉首0,不必去掉decimalstr的尾0(超出部分捨去)
if (!integerstr.equals(""))
} // overflow超出處理能力,直接返回
if (integerstr.length() > iunit.length)
int integers = toarray(integerstr);// 整數部分數字
boolean ismust5 = ismust5(integerstr);// 設定萬單位
int decimals = toarray(decimalstr);// 小數部分數字
return getchineseinteger(integers, ismust5)
+ getchinesedecimal(decimals);
} /**
* 整數部分和小數部分轉換為陣列,從高位至低位
*/private static int toarray(string number)
return array;
} /**
* 得到中文金額的整數部分。
*/private static string getchineseinteger(int integers, boolean ismust5)
: (numbers[integers[i]] + iunit[length - i - 1]));
} return chineseinteger.tostring();
} /**
* 得到中文金額的小數部分。
*/private static string getchinesedecimal(int decimals)
return chinesedecimal.tostring();
} /**
* 判斷第5位數字的單位"萬"是否應加。
*/private static boolean ismust5(string integerstr) else
return integer.parseint(subinteger) > 0;
} else
} public static void main(string args)
}
小寫金額轉換為大寫金額
我的乙個朋友寫的,金額轉成大寫 public static string convertmoney decimal dnum string str2 new string string strunit string.join str1 string struppernum string.join s...
小寫金額轉換為大寫金額
在很多地方都有用到將小寫金額轉換為大寫金額,就是將類似1234.56轉換為壹仟貳佰叄拾肆圓伍角陸分。到底要怎樣實現呢?其實只要仔細注意自己到底是怎麼讀的,細細揣摩一下。1 在千位 壹仟 2 在百位 貳佰.所以有兩個過程 1.講阿拉伯數字轉換為大寫數字。2.在各位後面加上諸如 萬 仟 佰 拾 圓 分 ...
C 實現小寫金額轉大寫金額
好久沒有寫部落格了。最近專案上用到小寫轉大寫金額,公司同事還準備寫一段 來實現,後來發現架構上有現成的。其實在銀行 進銷存 crm等系統中經常可能用到 獲取金額的大寫中文文字 返回 中文數字文字 mvarordollar 數字金額大小,mstrlanguage 字串語言 p 簡體中文 c 正體中文 ...