Interface LanguageFormatter

All Known Implementing Classes:
EnglishFormatter

public interface LanguageFormatter
  • Method Summary

    Modifier and Type
    Method
    Description
    dayAbbreviation(DayOfWeek day, int maxWidth)
    Returns an abbreviated weekday name suitable for width-constrained rendering.
    Returns the full weekday name.
    dayName(DayOfWeek day, int minWidth, int maxWidth)
    Returns a weekday name adapted to the given width constraints.
    Returns the language identifier handled by this formatter, for example "en".
    Returns an abbreviated month name.
    Returns the full month name.
    monthName(Month month, int minWidth, int maxWidth)
    Returns a month name adapted to the given width constraints.
    Returns the ordinal suffix for the given non-negative integer, if the language supports one.
    boolean
    Indicates 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

      String toCardinal(int value)
      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

      String toOrdinal(int value)
      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

      String ordinalSuffix(BigInteger value)
      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

      String dayAbbreviation(DayOfWeek day, int maxWidth)
      Returns an abbreviated weekday name suitable for width-constrained rendering.

      The meaning of maxWidth is 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

      String monthAbbreviation(Month month)
      Returns an abbreviated month name.

      Examples in English: January -> "Jan", September -> "Sep".

    • dayName

      String dayName(DayOfWeek day)
      Returns the full weekday name.

      Example in English: Monday -> "Monday".

    • dayName

      String dayName(DayOfWeek day, int minWidth, int maxWidth)
      Returns a weekday name adapted to the given width constraints.

      If no width was explicitly requested by the caller, maxWidth may 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

      String monthName(Month month)
      Returns the full month name.

      Example in English: January -> "January".

    • monthName

      String monthName(Month month, int minWidth, int maxWidth)
      Returns a month name adapted to the given width constraints.

      If no width was explicitly requested by the caller, maxWidth may 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.