Java Utililty Methods Money

List of utility methods to do Money

Description

The list of methods to do Money are organized into topic(s).

Method

String_getStrMoney(Object money)
get Str Money
String strMoney = "0";
if (money != null) {
    strMoney = money.toString();
    if (strMoney.equals(""))
        strMoney = "0";
return strMoney;
longdoubleToMoney(double value)
double To Money
if (value < 0)
    return (long) (value * 10000 - 0.5);
return (long) (value * 10000 + 0.5);
floatfMoney(float pfNum)
f Money
float lfNum;
if (pfNum >= 0f)
    lfNum = pfNum + .0025f;
else
    lfNum = pfNum - .0025f;
return lfNum;
intGetMoneyAmount(int amount, int CheckAmount)
Get Money Amount
if (amount >= CheckAmount) {
    int left = amount / CheckAmount;
    if (left > 0) {
        return left;
return 0;
booleanisMoney(String money)
is Money
if (!isNumber(money)) {
    return false;
if (money.equals("0")) {
    return false;
for (int i = 0; i < money.length(); i++) {
    char ch = money.charAt(i);
...
booleanisMoney(String money)
is Money
money = money.trim();
if (money.startsWith("$")) {
    return (false);
if (money.length() > 0 && money.trim().matches("^(\\d*(\\.\\d\\d?)?|\\d+)$")) {
    return (true);
} else {
    return (false);
...
booleanisMoney(String str)
is Money
for (int i = 0; i < str.length(); i++) {
    if (!Character.isDigit(str.charAt(i)))
        return false;
return true;
booleanisMoney(String[] Moneys, String key)
is Money
if (Moneys.length == 0)
    return false;
for (String moneyKey : Moneys) {
    if (moneyKey.equals(key)) {
        return true;
return false;
...
StringmoneyChange(String money)
money Change
int index = money.indexOf(".");
String head = money.substring(0, index);
String end = money.substring(index + 1);
if (head.equals("0")) {
    if (end.startsWith("0")) {
        return Integer.parseInt(end) + "";
    return end;
...
StringmoneyFenToYuan(String amount)
money Fen To Yuan
if (isEmpty(amount)) {
    return amount;
if (amount.indexOf(".") > -1) {
    return amount;
if (amount.length() == 1) {
    return "0.0" + amount;
...