Class AbstractDifferenceFormatter

java.lang.Object
com.github.toolarium.common.formatter.AbstractDifferenceFormatter
Direct Known Subclasses:
TimeDifferenceFormatter

public abstract class AbstractDifferenceFormatter extends Object
  • Constructor Details

    • AbstractDifferenceFormatter

      public AbstractDifferenceFormatter(String pattern, boolean spaceAfterValue)
      Constructor
      Parameters:
      pattern - the format pattern
      spaceAfterValue - true to have a space after the value
  • Method Details

    • formatAsString

      public String formatAsString(double value, int len)
      Formats the given value to a well formated string
      Parameters:
      value - the value difference
      len - the size of the string
      Returns:
      the formated string
    • formatAsString

      public String formatAsString(long value, int len)
      Formats the given value to a well formated string
      Parameters:
      value - the value difference
      len - the size of the string
      Returns:
      the formated string
    • formatAsString

      public String formatAsString(double value)
      Formats the given value to a well formated string
      Parameters:
      value - the value difference
      Returns:
      the formated string
    • formatAsString

      public abstract String formatAsString(long value)
      Formats the given value to a well formated string
      Parameters:
      value - the value difference
      Returns:
      the formated string
    • formatNumber

      public String formatNumber(double number, String trailer, boolean space)
      Formats a given number
      Parameters:
      number - the number to format
      trailer - the tailer
      space - add space between number and trailer
      Returns:
      the formated number
    • formatNumber

      protected String formatNumber(long number, String trailer, boolean space)
      Formats a given number
      Parameters:
      number - the number to format
      trailer - the tailer
      space - add space between number and trailer
      Returns:
      the formated number
    • addResult

      protected String addResult(long value, String trailer, String result)
      Gets a prepared string which contains the result and additional the given value
      Parameters:
      value - the value
      trailer - the trailer
      result - the current result
      Returns:
      the prepared string
    • getDecimalFormatter

      protected DecimalFormat getDecimalFormatter()
      Get the decimal formatter
      Returns:
      the decimal formatter
    • spaceAfterValue

      protected boolean spaceAfterValue()
      Defines if after a value follows a space
      Returns:
      true to add space after the value