java - Java 中使用什么类来表示货币?

标签 java class numbers currency

我正在开发一个用 Java 开发的金融项目,我想:

  • 建立货币换算系统
  • 转换它们并确保它们有效

我想知道什么是最好的 Java 类来使货币正常工作。归结为这两个选择:

  1. 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/

相关文章:

java - 如何恢复 BasicStroke 类中的默认笔画?

java - Class<?>#getTypeParameters() 的返回类型是什么?

c# - 如何检查一个字符串是否是一个(非常大的)数字?

c - 我自己的随机数生成器

iOS:我想将 "."添加到 NSInteger 并将其显示为 NSString

java - 通过 Java 使用来自 http ://www. webservicex.net 的 Web 服务

java - dojo中的domConstruct是抽象类吗

java - 配置 nutch regex-normalize.xml

class - PlantUML:如何控制同等级类的对齐?

c++ - 为什么我们可以从 C++ 中的成员函数访问非成员函数