Class FormatHelper

java.lang.Object
io.bdeploy.common.util.FormatHelper

public class FormatHelper extends Object
Contains static helpers to format various data types into a human readable format.
  • Method Details

    • formatDuration

      public static String formatDuration(long timeInMillis)
      Formats the given duration into a human readable format
    • formatRemainingTime

      public static String formatRemainingTime(long duration)
      Returns a human readable string of the given time. Only the most relevant unit is displayed.
       Sample output:  4 seconds
                       15 minutes
                       1 hour
       
      Parameters:
      duration - The duration in milliseconds
      Returns:
      The string representation.
    • formatTransferRate

      public static String formatTransferRate(long bytes, long timeInMs)
      Calculates and formats the transfer rate into a human readable string
      Parameters:
      bytes - the number of bytes that have been transfered
      timeInMs - the time in milliseconds that the transfer took
    • format

      public static String format(Date date)
      Formats the given date into a human readable string
    • format

      public static String format(TemporalAccessor temporal)
      Formats the given date into a human readable string
    • format

      public static String format(long timestamp)
      Formats the given date into a human readable string
    • formatFileSize

      public static String formatFileSize(long size)
      Formats the given file size in bytes into a human readable format;