4 ms·
How does it compare to the Java money API (https://jcp.org/en/jsr/detail?id=354 https://jcp.org/en/jsr/detail?id=354) and the related Kotlin DSL in https://gith
by hiddew 2y ago
How does it compare to the Java money API (https://jcp.org/en/jsr/detail?id=354 https://jcp.org/en/jsr/detail?id=354) and the related Kotlin DSL in https://github.com/hiddewie/money-kotlin/?tab=readme-ov-file#kotlin-extensions-for-javaxmoney-moneta-jsr-354 https://github.com/hiddewie/money-kotlin/?tab=readme-ov-file...?
- rafaelferreira 2y agoAnother library in this space is Eric Evans' (of DDD fame) Time & Money library https://timeandmoney.sourceforge.net/ https://timeandmoney.sourceforge.net/.
- stickfigure 2y agoI'm surprised nobody has mentioned Joda Money yet: https://www.joda.org/joda-money/ https://www.joda.org/joda-money/ From the same person that brought us Joda Time (ie, what the java time API was based on). I've used Joda Money a lot and it's great. Honestly I prefer APIs that look like APIs and I think this trend towards inventing DSLs is a bad one. Rails works because there's a critical mass of people who have adopted what is essentially a whole new language on top of Ruby. A money library doesn't warrant a new language, it's unnecessary cognitive load. This new money library would look fine with simple constructors and method calls.
- nogridbag 2y agoI personally went with Joda money versus the Java money API mentioned above. Our needs are a bit simpler and the Joda Money API is a bit simpler to understand. Our app only deals in USD so I wrote a small utility class to help initialize Money instances so devs don't have to write: Money.of(CurrencyUnit.USD, amount) ...everywhere and do a few other things like total Money instances.
- eriksencosta 2y agoJoda is impressive and has great performance. The examples were written using the infix notation but you can just use regular method calls. For example: val price = Money.of(100, "USD") val shipping = Money.of(5, "USD") val subtotal = price.plus(shipping) val discount = Percentage.of(10) val total = subtotal.decreaseBy(discount) total.allocate(2) total.allocate(60.percent(), 40.percent())