Class LocaleNumberFormatter
java.lang.Object
com.winterhavenmc.library.messagebuilder.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 LocaleProvider
.
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
(LocaleProvider localeProvider) Constructs a newLocaleNumberFormatter
with the given locale provider. -
Method Summary
Modifier and TypeMethodDescriptiongetFormatted
(Number number) Formats the specified number using theNumberFormat
instance associated with the locale provided by theLocaleProvider
.
-
Constructor Details
-
LocaleNumberFormatter
Constructs a newLocaleNumberFormatter
with the given locale provider.- Parameters:
localeProvider
- a provider ofLocale
instances used for formatting
-
-
Method Details
-
getFormatted
Formats the specified number using theNumberFormat
instance associated with the locale provided by theLocaleProvider
.- Specified by:
getFormatted
in interfaceNumberFormatter
- Parameters:
number
- the number to format- Returns:
- a localized string representation of the number
-