tobiasschuerg / android-money

Simple money and currency converter library for android.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is BigDecimal supported as input type?

longquangpham90 opened this issue · comments

Hi team dev!
We user library, but we want use BigDecimal Format number, library can not support

@longquangpham90 I don't really understand the issue, can you please explain?

You can create Money objects from BigDecimals already:

val pi = BigDecimal(3.14159265359)
Money(pi, usDollar)

Also for all operations BigDecimal is used internally

operator fun plus(money: Money): Money = when {
this.isZero() -> money
money.isZero() -> this
else -> {
requireSameCurrency(money)
val sum = amount.add(money.amount)
Money(sum, currency)
}
}

Does this address your issue?