All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.fasterxml.clustermate.service.util.SizeUtil Maven / Gradle / Ivy

There is a newer version: 0.10.5
Show newest version
package com.fasterxml.clustermate.service.util;

public class SizeUtil
{
    public static String sizeDesc(long amount)
    {
        // yeah I'm old-fashioned, kilo-byte is 2^10 bytes
        double kbs = amount / 1024.0;
        if (kbs < 1000.0) {
            return String.format("%.1f kB", kbs);
        }
        double mbs = kbs / 1024.0;
        if (mbs < 1000.0) {
            return String.format("%.1f MB", mbs);
        }
        double gigs = mbs / 1024.0;
        return String.format("%.1f GB", gigs);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy