quantify is a poor attempt to deal with the surprisingly difficult issue of representing the size of digital quantities.
It is notoriously hard to deal with the digital units of bytes and bits when representing and converting sizes of the file system and memory.
Do you use SI Units? Do you use the JEDEC Standard? How do you print a human readable string to System.out
? It is so hard that The most copied StackOverflow snippet of all time is flawed.
With quantify do yourself a favor and write code like this:
final Path file = Paths.get(...);
final long size = Files.size(file);
...
System.out.println(DataSizeFormatter.usingDefaultLocale().format(size, DecimalByteUnit.BYTES));
...
final long megabytes = DecimalByteUnit.BYTES.toMegabytes(bytes);
- Easy to use for common cases
- A simple, concise, and user-friendly API which caters to 90 percent of application needs
- Java 8 or higher
- No dependencies (other than the JDK)
- And more...
- Publish the project on Maven Central
- Should this project implement the JSR 385 specification (Units of Measurement API)?
Yes! Send me your patches and contributions. I will come up with a Contributor License Agreement.