Code example for BigDecimal

Methods: toPlainString

0
    } 
 
    public String format(Money money) {
        BigDecimal amount = money.getAmount();
        Currency currency = money.getCurrency();
        return new StringBuilder(amount.toPlainString()).
                append(" ").append(currency.getCurrencyCode()).toString();
    } 
 
    public Money parse(String value) {
        String[] parts = value != null ? value.split(" ") : EMPTY;
        switch (parts.length) {
            case 1: 
                return new Money(MathUtils.valueOf(parts[0]));
            case 2: 
                return new Money(MathUtils.valueOf(parts[0]), Currency.getInstance(parts[1]));
            default: 
                return Money.ZERO; 
        } 
    } 
}