Author name: javaplanet.io

Normalizer

he Normalizer class (from java.text in Java 5 and later java.text.Normalizer or java.text.Normalizer.Form) is used to transform Unicode text into a normalized form. This is crucial when comparing, storing, or searching strings that may be visually identical but have different internal Unicode representations (e.g., accented characters). Key Features: Ensures consistent Unicode representation Supports multiple normalization […]

Normalizer Read More »

NumberFormat

The NumberFormat class (from the java.text package) provides methods to format and parse numbers in a locale-sensitive manner. It is commonly used for formatting: General numbers Currency values Percentages Unlike DecimalFormat, NumberFormat provides default formats based on locale and is ideal for user-facing number displays. Key Features Locale-aware formatting Formats currency and percentages Parses strings

NumberFormat Read More »

DateFormat

DateFormat is an abstract class in the java.text package used to format and parse dates and times in a locale-sensitive manner. It is often used to convert Date objects to readable strings and parse strings back into Date objects. Key Features Format Date to String Parse String to Date Locale-sensitive formatting Supports different styles (FULL,

DateFormat Read More »

CollationKey

The CollationKey class (in java.text) is used in conjunction with Collator to optimize string comparison operations. When comparing many strings repeatedly, creating a CollationKey for each string once, and then comparing the keys instead of the strings, offers better performance. Key Features: Represents a string in a form that’s optimized for comparison Can be used

CollationKey Read More »

RuleBasedCollator

The RuleBasedCollator class, a subclass of Collator in java.text, allows custom string comparison rules. While Collator uses default locale-based rules, RuleBasedCollator gives you explicit control by defining your own rules. This is useful when: Locale rules are insufficient or undesired You need to sort based on domain-specific conventions (e.g., chemical names, custom dictionaries) Key Features:

RuleBasedCollator Read More »

Collator

The Collator class (part of java.text) is used for locale-sensitive string comparison. It enables accurate sorting and comparison of strings based on the rules of a specific language, making it useful for internationalization. Key Features: Locale-aware string comparison Supports different comparison strengths (primary, secondary, tertiary) Can sort lists of strings according to local conventions (e.g.,

Collator Read More »

MessageFormat

The MessageFormat class in java.text package is used to produce concatenated messages that include dynamic values, such as numbers, dates, or strings, in a template format. Unlike string concatenation, MessageFormat is locale-sensitive and cleaner for formatting complex messages with placeholders. Key Features: Supports indexed placeholders like {0}, {1}, etc. Can format numbers, dates, and strings.

MessageFormat Read More »

ChoiceFormat

ChoiceFormat is a subclass of NumberFormat used to map numeric ranges to custom strings. It is ideal when a numeric value should be translated into a human-readable category, such as converting scores to grades, salary ranges to designations, or item quantities to messages like “few”, “many”, etc. Key Features Maps numerical ranges to specific strings.

ChoiceFormat Read More »

Scroll to Top