Package com.saperion.common.lang.format
Class NumberFormatter
java.lang.Object
com.saperion.common.lang.format.NumberFormatter
Contains utility methods for
Number formatting.- Author:
- agz
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatWithThousandsSeparator(long value, char thousandsSeparator) Converts the specified long value to a string using the specified thousands separator.
-
Method Details
-
formatWithThousandsSeparator
Converts the specified long value to a string using the specified thousands separator. Usually one can useNumberFormatfor 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
-