Java - 用于表示重量和度量的类 [英] Java - Class to represent weight and measures

查看:553
本文介绍了Java - 用于表示重量和度量的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个现有的Java库来表示常见的权重和度量?我希望能够创建代表不同单位的重量和距离的物体,并让您进行比较。实现我自己并不难,但在这种情况下,我不想重新发明轮子,因为这个轮子不是很有趣!似乎有东西在Apache Commons沙箱,它适合我需要的东西,但我宁愿选择稳定的东西。

编辑:

能否提供如何在JScience中定义新单位类型的示例?阅读jscience.org上的文档,我不清楚这一点。

解决方案

在SourceForge上有Java数字单元库: Java数字与单位



另外,您可能对 JScience 感兴趣,但涉及更多。



我还发现: Java度量单位


Is there an existing Java library to represent common weights and measures? I would like something which allows you to create objects which represent weight and distances in different units and let you compare them. It wouldn't be too hard to implement myself, but in this case I don't want to re-invent the wheel, since this wheel isn't that interesting! There seems to be something in the Apache Commons sandbox which vaguely fits what I need, though I would prefer something stable.

Edit:

Would it be possible to provide an example of how to define a new unit type in JScience? I am not clear on this from reading the documentation on jscience.org.

解决方案

There is the Java Numbers with Unit library on SourceForge: Java Numbers with Unit

Also, you may be interested in JScience, but it is much more involved.

I also found: Java units of measure

这篇关于Java - 用于表示重量和度量的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆