Package com.saperion.common.lang.format
Class NumberFormatter
- java.lang.Object
-
- com.saperion.common.lang.format.NumberFormatter
-
public final class NumberFormatter extends java.lang.Object
Contains utility methods forNumber
formatting.- Author:
- agz
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.String
formatWithThousandsSeparator(long value, char thousandsSeparator)
Converts the specified long value to a string using the specified thousands separator.
-
-
-
Method Detail
-
formatWithThousandsSeparator
public static java.lang.String formatWithThousandsSeparator(long value, char thousandsSeparator)
Converts the specified long value to a string using the specified thousands separator. Usually one can useNumberFormat
for this purpose, but this class is overloaded with different aspects to parse and format a lot of different things, making it inefficient and resource intensive. This method is optimized for this single use case to save time and resources. It is approximately 5 times faster thanNumberFormat.format(long)
on a preparedNumberFormat
-instance and approximately 10 times faster than creating aNumberFormat
-instance and formatting then (likeNumberFormat.getInstance().format()
).- Parameters:
value
- value to formatthousandsSeparator
- thousands separator to use- Returns:
- formatted string for the specified long value
-
-