Class AbstractDifferenceFormatter
- java.lang.Object
-
- com.github.toolarium.common.formatter.AbstractDifferenceFormatter
-
- Direct Known Subclasses:
TimeDifferenceFormatter
public abstract class AbstractDifferenceFormatter extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description AbstractDifferenceFormatter(java.lang.String pattern, boolean spaceAfterValue)Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.lang.StringaddResult(long value, java.lang.String trailer, java.lang.String result)Gets a prepared string which contains the result and additional the given valuejava.lang.StringformatAsString(double value)Formats the given value to a well formated stringjava.lang.StringformatAsString(double value, int len)Formats the given value to a well formated stringabstract java.lang.StringformatAsString(long value)Formats the given value to a well formated stringjava.lang.StringformatAsString(long value, int len)Formats the given value to a well formated stringjava.lang.StringformatNumber(double number, java.lang.String trailer, boolean space)Formats a given numberprotected java.lang.StringformatNumber(long number, java.lang.String trailer, boolean space)Formats a given numberprotected java.text.DecimalFormatgetDecimalFormatter()Get the decimal formatterprotected booleanspaceAfterValue()Defines if after a value follows a space
-
-
-
Method Detail
-
formatAsString
public java.lang.String formatAsString(double value, int len)Formats the given value to a well formated string- Parameters:
value- the value differencelen- the size of the string- Returns:
- the formated string
-
formatAsString
public java.lang.String formatAsString(long value, int len)Formats the given value to a well formated string- Parameters:
value- the value differencelen- the size of the string- Returns:
- the formated string
-
formatAsString
public java.lang.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 java.lang.String formatAsString(long value)
Formats the given value to a well formated string- Parameters:
value- the value difference- Returns:
- the formated string
-
formatNumber
public java.lang.String formatNumber(double number, java.lang.String trailer, boolean space)Formats a given number- Parameters:
number- the number to formattrailer- the tailerspace- add space between number and trailer- Returns:
- the formated number
-
formatNumber
protected java.lang.String formatNumber(long number, java.lang.String trailer, boolean space)Formats a given number- Parameters:
number- the number to formattrailer- the tailerspace- add space between number and trailer- Returns:
- the formated number
-
addResult
protected java.lang.String addResult(long value, java.lang.String trailer, java.lang.String result)Gets a prepared string which contains the result and additional the given value- Parameters:
value- the valuetrailer- the trailerresult- the current result- Returns:
- the prepared string
-
getDecimalFormatter
protected java.text.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
-
-