Class EnglishFormatter
- All Implemented Interfaces:
LanguageFormatter
-
Constructor Summary
Constructors -
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.static StringtoEnglishCardinalWords(int value) static StringtoEnglishOrdinalWords(int value) toOrdinal(int value) Returns the ordinal word representation of a non-negative integer.
-
Constructor Details
-
EnglishFormatter
public EnglishFormatter()
-
-
Method Details
-
getLanguage
Description copied from interface:LanguageFormatterReturns the language identifier handled by this formatter, for example "en".- Specified by:
getLanguagein interfaceLanguageFormatter
-
supportsOrdinalSuffix
public boolean supportsOrdinalSuffix()Description copied from interface:LanguageFormatterIndicates whether the language supports suffix-based ordinal formatting.Examples: English: true Languages without productive ordinal suffixes: false
- Specified by:
supportsOrdinalSuffixin interfaceLanguageFormatter
-
ordinalSuffix
Description copied from interface:LanguageFormatterReturns 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
LanguageFormatter.supportsOrdinalSuffix()first.- Specified by:
ordinalSuffixin interfaceLanguageFormatter
-
toCardinal
Description copied from interface:LanguageFormatterReturns 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.
- Specified by:
toCardinalin interfaceLanguageFormatter
-
toOrdinal
Description copied from interface:LanguageFormatterReturns 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.
- Specified by:
toOrdinalin interfaceLanguageFormatter
-
dayAbbreviation
Description copied from interface:LanguageFormatterReturns 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.
- Specified by:
dayAbbreviationin interfaceLanguageFormatter
-
monthAbbreviation
Description copied from interface:LanguageFormatterReturns an abbreviated month name.Examples in English: January -> "Jan", September -> "Sep".
- Specified by:
monthAbbreviationin interfaceLanguageFormatter
-
dayName
Description copied from interface:LanguageFormatterReturns the full weekday name.Example in English: Monday -> "Monday".
- Specified by:
dayNamein interfaceLanguageFormatter
-
dayName
Description copied from interface:LanguageFormatterReturns 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.
- Specified by:
dayNamein interfaceLanguageFormatter
-
monthName
Description copied from interface:LanguageFormatterReturns the full month name.Example in English: January -> "January".
- Specified by:
monthNamein interfaceLanguageFormatter
-
monthName
Description copied from interface:LanguageFormatterReturns 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.
- Specified by:
monthNamein interfaceLanguageFormatter
-
toEnglishCardinalWords
-
toEnglishOrdinalWords
-