Money is a Kotlin library that makes monetary calculations and allocations easy:
val price = 100 money "USD" // USD 100.00
val shipping = 5 money "USD" // USD 5.00
val subtotal = price + shipping // USD 105.00
val discount = 10.percent() // 10%
val total = subtotal decreaseBy discount // USD 94.50
val ratios = listOf(60.percent(), 40.percent()) // [60%, 40%]
total allocate 2 // [USD 47.25, USD 47.25]
total allocate ratios // [USD 56.70, USD 37.80]
The previous example shows at a glance how the library works. Discover more in the usage guide.
- Money and currencies: understand how to define monetary amounts and currencies
- Operations: get a complete picture of the supported operations
- Rounding: learn how flexible are the rounding options for your use cases
- Allocation: calculate installments correctly by using the allocation features
- Performance: fine tune the library cache for your performance requirements
- Circulating currencies: details the library support for circulating currencies alongside a table with all supported currencies and their data
- Cryptocurrencies: details the library support for cryptocurrencies alongside a table with all supported currencies and their data
Browse the API documentation for further technical details.