Class FormatUtils
FormatUtils is thread-safe and immutable.
- Since:
- 1.0
- Author:
- Brian S O'Neill
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidappendPaddedInteger(Appendable appenadble, int value, int size) Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given appendable.static voidappendPaddedInteger(Appendable appendable, long value, int size) Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer.static voidappendPaddedInteger(StringBuffer buf, int value, int size) Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer.static voidappendPaddedInteger(StringBuffer buf, long value, int size) Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer.static voidappendUnpaddedInteger(Appendable appendable, int value) Converts an integer to a string, and appends it to the given appendable.static voidappendUnpaddedInteger(Appendable appendable, long value) Converts an integer to a string, and appends it to the given appendable.static voidappendUnpaddedInteger(StringBuffer buf, int value) Converts an integer to a string, and appends it to the given buffer.static voidappendUnpaddedInteger(StringBuffer buf, long value) Converts an integer to a string, and appends it to the given buffer.static intcalculateDigitCount(long value) Calculates the number of decimal digits for the given value, including the sign.static voidwritePaddedInteger(Writer out, int value, int size) Converts an integer to a string, prepended with a variable amount of '0' pad characters, and writes it to the given writer.static voidwritePaddedInteger(Writer out, long value, int size) Converts an integer to a string, prepended with a variable amount of '0' pad characters, and writes it to the given writer.static voidwriteUnpaddedInteger(Writer out, int value) Converts an integer to a string, and writes it to the given writer.static voidwriteUnpaddedInteger(Writer out, long value) Converts an integer to a string, and writes it to the given writer.
-
Method Details
-
appendPaddedInteger
Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer.This method is optimized for converting small values to strings.
- Parameters:
buf- receives integer converted to a stringvalue- value to convert to a stringsize- minimum amount of digits to append
-
appendPaddedInteger
public static void appendPaddedInteger(Appendable appenadble, int value, int size) throws IOException Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given appendable.This method is optimized for converting small values to strings.
- Parameters:
appenadble- receives integer converted to a stringvalue- value to convert to a stringsize- minimum amount of digits to append- Throws:
IOException- if an IO error occurs- Since:
- 2.4
-
appendPaddedInteger
Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer.This method is optimized for converting small values to strings.
- Parameters:
buf- receives integer converted to a stringvalue- value to convert to a stringsize- minimum amount of digits to append
-
appendPaddedInteger
public static void appendPaddedInteger(Appendable appendable, long value, int size) throws IOException Converts an integer to a string, prepended with a variable amount of '0' pad characters, and appends it to the given buffer.This method is optimized for converting small values to strings.
- Parameters:
appendable- receives integer converted to a stringvalue- value to convert to a stringsize- minimum amount of digits to append- Throws:
IOException- if an IO error occurs- Since:
- 2.4
-
writePaddedInteger
Converts an integer to a string, prepended with a variable amount of '0' pad characters, and writes it to the given writer.This method is optimized for converting small values to strings.
- Parameters:
out- receives integer converted to a stringvalue- value to convert to a stringsize- minimum amount of digits to append- Throws:
IOException- if an IO error occurs
-
writePaddedInteger
Converts an integer to a string, prepended with a variable amount of '0' pad characters, and writes it to the given writer.This method is optimized for converting small values to strings.
- Parameters:
out- receives integer converted to a stringvalue- value to convert to a stringsize- minimum amount of digits to append- Throws:
IOException- if an IO error occurs
-
appendUnpaddedInteger
Converts an integer to a string, and appends it to the given buffer.This method is optimized for converting small values to strings.
- Parameters:
buf- receives integer converted to a stringvalue- value to convert to a string
-
appendUnpaddedInteger
Converts an integer to a string, and appends it to the given appendable.This method is optimized for converting small values to strings.
- Parameters:
appendable- receives integer converted to a stringvalue- value to convert to a string- Throws:
IOException- if an IO error occurs- Since:
- 2.4
-
appendUnpaddedInteger
Converts an integer to a string, and appends it to the given buffer.This method is optimized for converting small values to strings.
- Parameters:
buf- receives integer converted to a stringvalue- value to convert to a string
-
appendUnpaddedInteger
Converts an integer to a string, and appends it to the given appendable.This method is optimized for converting small values to strings.
- Parameters:
appendable- receives integer converted to a stringvalue- value to convert to a string- Throws:
IOException- if an IO error occurs
-
writeUnpaddedInteger
Converts an integer to a string, and writes it to the given writer.This method is optimized for converting small values to strings.
- Parameters:
out- receives integer converted to a stringvalue- value to convert to a string- Throws:
IOException- if an IO error occurs
-
writeUnpaddedInteger
Converts an integer to a string, and writes it to the given writer.This method is optimized for converting small values to strings.
- Parameters:
out- receives integer converted to a stringvalue- value to convert to a string- Throws:
IOException- if an IO error occurs
-
calculateDigitCount
public static int calculateDigitCount(long value) Calculates the number of decimal digits for the given value, including the sign.- Parameters:
value- the value- Returns:
- the digit count
-