class DateTimeExt {

    public static String toRateString(long interval, long itemsPerInterval, TimeUnit timeUnit, String rateType) {
        TimeUnit matchedTimeUnit = timeUnit;
        for (TimeUnit nextTimeUnit : TimeUnit.values()) {
            double ratio = nextTimeUnit.toNanos(1) / (double) timeUnit.toNanos(1);
            double rate = itemsPerInterval / (double) interval * ratio;
            if (rate >= 0.1) {
                matchedTimeUnit = nextTimeUnit;
                break;
            }
        }
        double ratio = matchedTimeUnit.toNanos(1) / (double) timeUnit.toNanos(1);
        double rate = itemsPerInterval / (double) interval * ratio;

        return String.format("%.2f %s/%s", rate, rateType, toTimeUnitAbbreviation(matchedTimeUnit));
    }

    private  DateTimeExt();

}