Class NumericFormat

java.lang.Object
net.storm.sdk.commons.NumericFormat

public class NumericFormat extends Object
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:
  • invalid reference
    Statistic
  • Constructor Details

    • NumericFormat

      public NumericFormat()
  • Method Details

    • precision

      public static int precision(int precision)
      Creates a precision setting value for use with apply(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

      public static String apply(long value)
      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

      public static String apply(long value, int settings)
      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 format
      settings - the formatting settings (combined flags)
      Returns:
      the formatted string representation