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

org.opentripplanner.common.LoggingUtil Maven / Gradle / Ivy

package org.opentripplanner.common;

import java.util.Locale;

/**
 * Utility functions for logging output.
 */
public class LoggingUtil {

    public static String fileSizeToString(long n) {
        if (n >= 1_000_000_000) {
            return String.format(Locale.ROOT, "%.1f GB", n/1_000_000_000.0);
        }
        if (n >= 1_000_000) {
            return String.format(Locale.ROOT, "%.1f MB", n/1_000_000.0);
        }
        if (n >= 1_000) {
            return String.format(Locale.ROOT, "%d kb", n/1_000);
        }
        if (n == 1) {
            return String.format(Locale.ROOT, "%d byte", n);
        }
        else {
            return String.format(Locale.ROOT, "%d bytes", n);
        }
    }

    /* private methods */

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy