changeF2Y static method
fen to yuan, format output. 分 转 元, format格式输出.
Implementation
static String changeF2Y(int amount,
{MoneyFormat format = MoneyFormat.normal}) {
String moneyTxt;
double yuan = NumUtil.divide(amount, 100);
switch (format) {
case MoneyFormat.normal:
moneyTxt = yuan.toStringAsFixed(2);
break;
case MoneyFormat.endInteger:
if (amount % 100 == 0) {
moneyTxt = yuan.toInt().toString();
} else if (amount % 10 == 0) {
moneyTxt = yuan.toStringAsFixed(1);
} else {
moneyTxt = yuan.toStringAsFixed(2);
}
break;
case MoneyFormat.yuanInteger:
moneyTxt = (amount % 100 == 0)
? yuan.toInt().toString()
: yuan.toStringAsFixed(2);
break;
}
return moneyTxt;
}