package com.its.app.utils;

public class Converter {
    private Converter() {
    }

    public static String getSize(double bytes) {
        long kilo = 1024L;
        double kb = bytes / 1024.0D;
        double mb = kb / 1024.0D;
        double gb = mb / 1024.0D;
        double tb = gb / 1024.0D;
        if (tb > 1.0D) {
            return String.format("%.2f TB", tb);
        } else if (gb > 1.0D) {
            return String.format("%.2f GB", gb);
        } else if (mb > 1.0D) {
            return String.format("%.2f MB", mb);
        } else {
            return kb > 1.0D ? String.format("%.2f KB", kb) : String.format("%.2f Bytes", bytes);
        }
    }
}
