A small library that will help you to get convenient for analyzing values. For instance, a big amount of seconds or bytes.
<dependency> <groupId>com.github.bogdanovmn.humanreadablevalues</groupId> <artifactId>human-readable-values</artifactId> <version>...</version> </dependency>assertEquals( "1h 1s 50ms", new MillisecondsValue(3600_000 + 1050).fullString() ); assertEquals( "1.1s", new MillisecondsValue(1050).shortString() );assertEquals( "2h 46m 40s", new SecondsValue(10000).fullString() ); assertEquals( "2.8h", new SecondsValue(10000).shortString() );assertEquals( "9K 784b", new BytesValue(10000).fullString() ); assertEquals( "9.8K", new BytesValue(10000).shortString() );public class MyTypeValue extends FractionatedValue { public MyTypeValue(long value) { super( value, new FractionSpecification( FractionDefinition.builder() .name("the minimal fraction unit") .shortNotation("mu") .minimalUnitsAmount(1) .build(), FractionDefinition.builder() .name("another fraction unit") .shortNotation("afu") .minimalUnitsAmount(60) .build(), FractionDefinition.builder() .name("the last fraction unit") .shortNotation("lfu") .minimalUnitsAmount(3600) .build() ) ); } }assertEquals( "2lfu 46afu 40mu", new MyTypeValue(10000).fullString() );The base class FractionatedValue has methods that return components of the divided on fractions value so you can use them for your better formatting