简体   繁体   English

如何使用 Java 的新度量单位 API 舍入数量?

[英]How to round Quantitys using Java's new Units of Measurement API?

How do I round javax.measure.Quantity s?我如何舍入javax.measure.Quantity s? There's got to be a way but I can't seem to find it.一定有办法,但我似乎找不到。

If I've got 1.242742384474667939234868368726636 mph , how do I get to 1.2 mph ?如果我有1.242742384474667939234868368726636 mph ,我如何达到1.2 mph

You can use the getValue() method to get the value.您可以使用 getValue() 方法来获取值。 Round the value, and then create a new Quantity with the rounded value and the original units舍入该值,然后使用舍入后的值和原始单位创建一个新的 Quantity

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM