commercetools / commercetools-jvm-sdk

The e-commerce SDK from commercetools running on the Java virtual machine.
https://commercetools.github.io/commercetools-jvm-sdk/apidocs/index.html
Other
62 stars 40 forks source link

Migrate to Java money #121

Closed schleichardt closed 9 years ago

schleichardt commented 9 years ago

@lauraluiz @OlegIlyenko

Currently the currency code of money is typed as String. Should we change this? http://www.joda.org/joda-money/ uses also a special type.

Javadoc: http://sphereio.github.io/sphere-jvm-sdk/javadoc/master/io/sphere/sdk/models/Money.html

hajoeichler commented 9 years ago

Joda rules the world ;) @schleichardt Can you check how it handles floating point numbers that are smaller than one cent as Sphere does only support full cents at the moment.

lauraluiz commented 9 years ago

In the old SDK sometimes (I wonder why not everywhere) the Java class Currency is used, for example here: https://github.com/commercetools/sphere-play-sdk/blob/5456d2057c4423d617ba7cc5bf11b516a79baa10/java-client/src/main/java/io/sphere/client/shop/model/LineItemContainer.java#L128

I agree the String for currency code is not nice at all, we should use a class for that. Which one, I don't have any preference.

OlegIlyenko commented 9 years ago

If you want to work with money and currency in java then JSR 354 is the way to go, in my opinion.

schleichardt commented 9 years ago

But we are on Java 8, not on Java 9 draft, so JSR 354 ist not an option, yet.

OlegIlyenko commented 9 years ago

It's actually very viable solution. i already used it in several java 6 and java 7 projects. Even though it is not included in JDK yet, you can already use it as a java library:

http://javamoney.github.io/

It's hosted on github and available in maven central:

Reference implantation: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22moneta%22 API: http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22money-api%22

schleichardt commented 9 years ago

Okay, we go this way.

"org.javamoney" % "moneta" % "0.8"
hajoeichler commented 9 years ago

:+1:

OlegIlyenko commented 9 years ago

:+1:

schleichardt commented 9 years ago

Cool 0.9 is available.

schleichardt commented 9 years ago

http://bed-con.org/2013/wp-content/uploads/2013/04/JSR354-CSLayout_en_CD.pdf

OlegIlyenko commented 9 years ago

I actually was on this presentation. It was pretty cool (bedconf 2013). I think you can also find some videos of it.

Best regards, Oleg

On 02 Oct 2014, at 09:53, Michael Schleichardt notifications@github.com wrote:

http://bed-con.org/2013/wp-content/uploads/2013/04/JSR354-CSLayout_en_CD.pdf

— Reply to this email directly or view it on GitHub.