package com.tsi.app.common.utils;

public class Converter {

    private Converter() {}

    public static String getSize(double bytes) {
        final long kilo = 1024;

        double kb = bytes / kilo;
        double mb = kb / kilo;
        double gb = mb / kilo;
        double tb = gb / kilo;

        if (tb > 1.0D) return String.format("%.2f TB", tb);
        if (gb > 1.0D) return String.format("%.2f GB", gb);
        if (mb > 1.0D) return String.format("%.2f MB", mb);
        if (kb > 1.0D) return String.format("%.2f KB", kb);

        return String.format("%.2f Bytes", bytes);
    }
}
