Java formatters is a easy library to format time in seconds or bytes. It’s main purpose is to show only smallest amount possible and transform bytes or seconds to human readable form. For instance if time is less than hour and more or equal to minute only minutes and seconds are shown. Similar pattern is used for bytes.
String out = SecondsFormatter.format(long secons); - fills from seconds to days (if necessary, so, if time can be shown in seconds then only seconds are shown etc..) String out = ByteFormatter.format(long size); /returns in B - TB
Source code can be downloaded from SourceForge.