private static <T> String withPercentage(final Object originalValue,
                                             final T value,
                                             final T total) {
        if (value == null || total == null) {
            return null;
        } else {
            if (value instanceof Duration) {
                return withPercentage(value,
                        ((Duration) value).toMillis(),
                        ((Duration) total).toMillis());
            } else if (value instanceof final DurationAdder durationAdder) {
                return withPercentage(value,
                        durationAdder.toMillis(),
                        ((DurationAdder) total).toMillis());
            } else if (value instanceof final DurationTimer durationTimer) {
                return withPercentage(value,
                        durationTimer.get().toMillis(),
                        ((DurationTimer) total).get().toMillis());
            } else if (value instanceof Number) {
                final double valNum = ((Number) value).doubleValue();
                final double totalNum = ((Number) total).doubleValue();
                if (totalNum == 0) {
                    return originalValue + " (undefined%)";
                } else {
//                    final int pct = (int) (valNum / totalNum * 100);

                    BigDecimal pct = BigDecimal.valueOf(valNum / totalNum * 100)
                            .stripTrailingZeros()
                            .round(new MathContext(3, RoundingMode.HALF_UP));
                    return originalValue + " (" + pct.toPlainString() + "%)";
                }
            } else {
                throw new IllegalArgumentException("Type "
                                                   + value.getClass().getSimpleName()
                                                   + " not supported");
            }
        }
    }
Returns the simple class name with the message, useful as some exception messages
only make sense if you know the class name, e.g. {@link NullPointerException} and
some {@link java.io.IOException}s.
stroom-util/src/main/java/stroom/util/logging/LogUtil.java