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

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

There is a newer version: 2.6.0
Show newest version
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 - 2025 Weber Informatics LLC | Privacy Policy