2015-06-17 14:03 GMT+02:00 David Blevins <david.blev...@gmail.com>: > I'd be happy to donate these if we want them: > > > https://raw.githubusercontent.com/tomitribe/tomitribe-util/master/src/main/java/org/tomitribe/util/SizeUnit.java > > https://raw.githubusercontent.com/tomitribe/tomitribe-util/master/src/test/java/org/tomitribe/util/SizeUnitTest.java > > Which commons lib would these go in? (can send a patch) >
Very nice! We would add this to Commons IO. You can contribute via github, if you like [1]. There are a few things to take into account imho: - Differenciate between decimal and binary prefixes, e.g. 1 Megabyte = 1000 Kilobyte, but 1 Mebibyte = 1024 Kibibyte. Not sure whether this is really that important. - Petta, Exa, Zetta and Yotta prefixes are missing. At least Petta my become important soon. - What about translations to bits? For example band width are often calculated in Mega Bits/sec - What about overflows when translating for example Exabytes to Bytes? The result won't fit into a long. I've also put an enum together but without translation logic, because of the overflow problem [2]. Maybe the implementations can be merged some how? Benedikt [1] https://github.com/apache/commons-io [2] https://issues.apache.org/jira/secure/attachment/12694350/IO-294_FileSizeUnit.patch > > > -David > > On Wed, Jun 17, 2015 at 8:50 AM, Gary Gregory <garydgreg...@gmail.com> > wrote: > > > Hi All: > > > > Java 5 introduced TimeUnit, a very nice enum. > > > > What do you all think of a ByteSizeUnit enum to handle bit, nibble, byte, > > kilobyte, kilobit, megabyte and so on? > > > > Gary > > > > -- > > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > > Java Persistence with Hibernate, Second Edition > > <http://www.manning.com/bauer3/> > > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > > Spring Batch in Action <http://www.manning.com/templier/> > > Blog: http://garygregory.wordpress.com > > Home: http://garygregory.com/ > > Tweet! http://twitter.com/GaryGregory > > > -- http://people.apache.org/~britter/ http://www.systemoutprintln.de/ http://twitter.com/BenediktRitter http://github.com/britter