Interface LanguageFormatter
- All Known Implementing Classes:
EnglishFormatter
-
Method Summary
Modifier and TypeMethodDescriptiondayAbbreviation(DayOfWeek day, int maxWidth) Returns an abbreviated weekday name suitable for width-constrained rendering.Returns the full weekday name.Returns a weekday name adapted to the given width constraints.Returns the language identifier handled by this formatter, for example "en".monthAbbreviation(Month month) Returns an abbreviated month name.Returns the full month name.Returns a month name adapted to the given width constraints.ordinalSuffix(BigInteger value) Returns the ordinal suffix for the given non-negative integer, if the language supports one.booleanIndicates whether the language supports suffix-based ordinal formatting.toCardinal(int value) Returns the cardinal word representation of a non-negative integer.toOrdinal(int value) Returns the ordinal word representation of a non-negative integer.
-
Method Details
-
getLanguage
String getLanguage()Returns the language identifier handled by this formatter, for example "en". -
toCardinal
Returns the cardinal word representation of a non-negative integer.Examples in English: 0 -> "zero", 15 -> "fifteen", 42 -> "forty-two".
The implementation should support at least the full non-negative Java int range.
-
toOrdinal
Returns the ordinal word representation of a non-negative integer.Examples in English: 1 -> "first", 15 -> "fifteenth", 42 -> "forty-second".
The implementation should support at least the full non-negative Java int range.
-
ordinalSuffix
Returns the ordinal suffix for the given non-negative integer, if the language supports one.Examples in English: 1 -> "st", 2 -> "nd", 11 -> "th".
If the language does not support ordinal suffixes, implementations may return the empty string, but callers should normally consult
supportsOrdinalSuffix()first. -
supportsOrdinalSuffix
boolean supportsOrdinalSuffix()Indicates whether the language supports suffix-based ordinal formatting.Examples: English: true Languages without productive ordinal suffixes: false
-
dayAbbreviation
Returns an abbreviated weekday name suitable for width-constrained rendering.The meaning of
maxWidthis language-specific but should be interpreted as the maximum desired character width for the abbreviation when possible.Examples in English: Monday -> "Mon", Tuesday -> "Tue" or "Tues" depending on width.
-
monthAbbreviation
Returns an abbreviated month name.Examples in English: January -> "Jan", September -> "Sep".
-
dayName
Returns the full weekday name.Example in English: Monday -> "Monday".
-
dayName
Returns a weekday name adapted to the given width constraints.If no width was explicitly requested by the caller,
maxWidthmay be negative. In that case, implementations should generally return the default full weekday name.When a width constraint is present, implementations may choose either a full or abbreviated form as long as it fits the requested width in a deterministic and language-appropriate way.
-
monthName
Returns the full month name.Example in English: January -> "January".
-
monthName
Returns a month name adapted to the given width constraints.If no width was explicitly requested by the caller,
maxWidthmay be negative. In that case, implementations should generally return the default full month name.When a width constraint is present, implementations may choose either a full or abbreviated form as long as it fits the requested width in a deterministic and language-appropriate way.
-