Class EnglishLanguageHandler
- All Implemented Interfaces:
LanguageHandler
LanguageHandler.
This handler converts numeric amounts to English textual representation using standard
English conventions. It implements the complete conversion logic previously found in
EnglishConvertHandler.
English Number Formatting Rules
This converter implements standard English number-to-word conventions:
- Hyphens for compound numbers: Twenty-Five, Ninety-Nine, etc.
- Position words: Hundred, Thousand, Million
- Capitalization: Each word starts with capital letter
- Spacing: Position words separated by spaces
- Zero handling: Single 0 = "Zero", portions of 0 = omitted
Unit Words
- "Baht" - Currency unit
- "Satang" - Fractional unit
- "Only" - Exact indicator (used when satang is zero)
Examples
handler.convert(ThaiBaht.of(new BigDecimal("100.00"), config));
// Output: "One Hundred Baht Only"
handler.convert(ThaiBaht.of(new BigDecimal("1234.56"), config));
// Output: "One Thousand Two Hundred Thirty-Four Baht Fifty-Six Satang"
- Since:
- 2.0.0
- Author:
- Zazalng
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionConverts the amount in the givenThaiBahtinstance to language-specific text.Returns the exact/only indicator word displayed when satang (fractional part) is zero.Returns the language code identifier for this handler.Returns the human-readable name of this language.Returns the default prefix applied to negative amounts.Returns the satang (fractional currency unit) word.Returns the currency unit word for the integer (baht) part.
-
Constructor Details
-
EnglishLanguageHandler
public EnglishLanguageHandler()
-
-
Method Details
-
convert
Description copied from interface:LanguageHandlerConverts the amount in the givenThaiBahtinstance to language-specific text.The implementation must respect the configuration options from
baht.getConfig(), including unit word inclusion, custom format templates, and negative prefix settings.- Specified by:
convertin interfaceLanguageHandler- Parameters:
baht- theThaiBahtinstance containing amount and configuration, never null- Returns:
- the language-specific textual representation of the amount, never null
-
getLanguageCode
Description copied from interface:LanguageHandlerReturns the language code identifier for this handler.This is typically a two or three-letter ISO 639 code (e.g., "th" for Thai, "en" for English).
- Specified by:
getLanguageCodein interfaceLanguageHandler- Returns:
- the language code, never null or empty
-
getLanguageName
Description copied from interface:LanguageHandlerReturns the human-readable name of this language.This is typically used for display and identification purposes.
- Specified by:
getLanguageNamein interfaceLanguageHandler- Returns:
- the language name (e.g., "Thai", "English"), never null or empty
-
getUnitWord
Description copied from interface:LanguageHandlerReturns the currency unit word for the integer (baht) part.Examples:
- Thai: "บาท" (Baht)
- English: "Baht"
- Laotian: "ກີບ" (Kip)
- Specified by:
getUnitWordin interfaceLanguageHandler- Returns:
- the unit word, never null or empty
-
getExactWord
Description copied from interface:LanguageHandlerReturns the exact/only indicator word displayed when satang (fractional part) is zero.Examples:
- Thai: "ถ้วน" (Exact/Full)
- English: "Only"
- Specified by:
getExactWordin interfaceLanguageHandler- Returns:
- the exact indicator word, never null or empty
-
getSatangWord
Description copied from interface:LanguageHandlerReturns the satang (fractional currency unit) word.Examples:
- Thai: "สตางค์" (Satang)
- English: "Satang"
- Specified by:
getSatangWordin interfaceLanguageHandler- Returns:
- the satang unit word, never null or empty
-
getNegativePrefix
Description copied from interface:LanguageHandlerReturns the default prefix applied to negative amounts.This prefix is used when the amount is negative, unless explicitly overridden via
ThaiBahtConfig.Builder.setPrefix(String).Examples:
- Thai: "ลบ" (Thai minus symbol)
- English: "Minus"
- Specified by:
getNegativePrefixin interfaceLanguageHandler- Returns:
- the negative prefix, never null or empty
-