views:

99

answers:

2

Hi, 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.

+4  A: 

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.

aberrant80
+2  A: 

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/

Dean Povey