Class TextFormatter

java.lang.Object
com.helger.base.text.TextFormatter

@Immutable public final class TextFormatter extends Object
Helper class for formatting text using MessageFormat patterns with locale-aware formatting.
Author:
Philip Helger
  • Method Details

    • getFormattedText

      public static @Nullable String getFormattedText(@Nullable String sText, @Nullable Object... aArgs)
      Format the given text using MessageFormat with the default format locale. If no arguments are provided, the text is returned unchanged.
      Parameters:
      sText - The message pattern to format. May be null.
      aArgs - The arguments to be substituted into the pattern. May be null.
      Returns:
      The formatted text, or null if the input text is null.
    • getFormattedText

      public static @Nullable String getFormattedText(@NonNull Locale aDisplayLocale, @Nullable String sText, @Nullable Object... aArgs)
      Format the given text using MessageFormat with the specified locale. If no arguments are provided, the text is returned unchanged.
      Parameters:
      aDisplayLocale - The locale to use for formatting. May not be null.
      sText - The message pattern to format. May be null.
      aArgs - The arguments to be substituted into the pattern. May be null.
      Returns:
      The formatted text, or null if the input text is null.