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