我正在开发一个用 Java
开发的金融项目,我想:
- 建立货币换算系统
- 转换它们并确保它们有效
我想知道什么是最好的 Java 类来使货币正常工作。归结为这两个选择:
BigDecimal
双
您能再向我解释一下这项工作的最佳选择是什么吗?
最佳答案
我的建议是BigDecimal
检查this出来。
This is a project to develop code for manipulating basic concepts in recurring domains such as time and money. The design principles followed here are explained in Part III of the book Domain-Driven Design. Read the credits here and release notes here. For some of the conceptual workings, you can read this explanation of time algebra and this explanation of interval math.
在这里他们还使用了 BigDecimal 。再次对您有帮助 Rounding and Scaling在 BigDecimal 中。
关于java - Java 中使用什么类来表示货币?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25256885/