java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.pipeline.formatters.number.LocaleNumberFormatter
All Implemented Interfaces:
NumberFormatter

public class LocaleNumberFormatter extends Object implements NumberFormatter
A locale-aware implementation of the NumberFormatter interface that formats numeric values using the default number format for the locale provided by a ConfigRepository.

This class is used throughout the message formatting pipeline to produce human-readable, properly localized number strings (e.g., for coordinates, quantities, etc.).

For example, the number 12345.67 might be formatted as "12,345.67" in Locale.US, or as "12 345,67" in Locale.FRANCE, depending on the locale.

See Also:
  • Constructor Details

    • LocaleNumberFormatter

      public LocaleNumberFormatter(ConfigRepository configRepository)
      Constructs a new LocaleNumberFormatter with the given locale provider.
      Parameters:
      configRepository - a provider of Locale instances used for formatting
  • Method Details

    • format

      public String format(Number number)
      Formats the specified number using the NumberFormat instance associated with the locale provided by the ConfigRepository.
      Specified by:
      format in interface NumberFormatter
      Parameters:
      number - the number to format
      Returns:
      a localized string representation of the number