Java中内置的存储单元转换实用程序?
Java 中似乎没有现有的 util 类用于将存储单元从一个存储单元转换为另一个存储单元,对吗? 还是有一个我实际上不知道的?
我正在寻找类似 java.util.concurrent.TimeUnit 实用程序。 我可以自己实现存储单元的等效功能,但只是想在重新发明轮子之前先问一下。
谢谢。
there doesn't seem to be an existing util class for converting a storage unit from one to another in Java, am I right? Or is there one actually I wasn't aware of?
What I was looking for is something like java.util.concurrent.TimeUnit utility. I can implement the equivalent for storage unit by myself, but just thought I would ask first before reinventing the wheel.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 JSR-275。 根据您想要做什么,可能有点矫枉过正。 或者您可以查看Commons Monitoring。 我认为它们处理一些存储单元,但同样,当只需要类时,库本身可能太多了。
Check out JSR-275. Depending on what you want to do, might be a bit of an overkill. Or you could take a look at Commons Monitoring. They deal with some storage units I think, but again, the library itself is probably too much when want just the class.
对于您的需求来说,这可能有些过头了,但 JSR-275 是一个用于单位和转换的 Java API,其中包括 DataAmount 和 DataRate。 有一个可用的参考实现。
请参阅 https://jsr-275.dev.java.net/
It may be overkill for what you need but JSR-275 is a Java API for units and conversions which includes DataAmount and DataRate. There is a reference implementation available.
See https://jsr-275.dev.java.net/