Class LocaleNumberFormatter
java.lang.Object
com.winterhavenmc.library.messagebuilder.adapters.pipeline.formatters.number.LocaleNumberFormatter
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionLocaleNumberFormatter(ConfigRepository configRepository) Constructs a newLocaleNumberFormatterwith the given locale provider. -
Method Summary
Modifier and TypeMethodDescriptionFormats the specified number using theNumberFormatinstance associated with the locale provided by theConfigRepository.
-
Constructor Details
-
LocaleNumberFormatter
Constructs a newLocaleNumberFormatterwith the given locale provider.- Parameters:
configRepository- a provider ofLocaleinstances used for formatting
-
-
Method Details
-
format
Formats the specified number using theNumberFormatinstance associated with the locale provided by theConfigRepository.- Specified by:
formatin interfaceNumberFormatter- Parameters:
number- the number to format- Returns:
- a localized string representation of the number
-