Package net.storm.sdk.commons
Class NumericFormat
java.lang.Object
net.storm.sdk.commons.NumericFormat
A utility class for formatting numeric values into human-readable strings.
This class provides methods to format large numbers with:
- Thousands separators (commas)
- Abbreviations (K, M, B, T for thousands, millions, billions, trillions)
- Configurable decimal precision
Example outputs:
- 1234 -> "1,234"
- 12345 -> "12.34K"
- 1234567 -> "1.23M"
- 1234567890 -> "1.23B"
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringapply(long value) Formats a numeric value with default settings.static Stringapply(long value, int settings) Formats a numeric value with custom settings.static intprecision(int precision) Creates a precision setting value for use withapply(long, int).
-
Constructor Details
-
NumericFormat
public NumericFormat()
-
-
Method Details
-
precision
public static int precision(int precision) Creates a precision setting value for use withapply(long, int).The precision determines how many decimal places are shown when using abbreviated format.
- Parameters:
precision- the number of decimal places (0-15)- Returns:
- the encoded precision setting
-
apply
Formats a numeric value with default settings.Default settings include:
- Thousands abbreviations enabled
- Comma separators enabled
- 2 decimal places precision
- Parameters:
value- the numeric value to format- Returns:
- the formatted string representation
-
apply
Formats a numeric value with custom settings.Settings can be combined using bitwise OR:
- COMMAS (0x1) - Enable comma separators
- THOUSANDS (0x40) - Enable K/M/B/T abbreviations
- precision(n) - Set decimal precision to n places
- Parameters:
value- the numeric value to formatsettings- the formatting settings (combined flags)- Returns:
- the formatted string representation
-