Package com.helger.base.text
Class TextFormatter
java.lang.Object
com.helger.base.text.TextFormatter
Helper class for formatting text using
MessageFormat
patterns with locale-aware formatting.- Author:
- Philip Helger
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable StringgetFormattedText(@Nullable String sText, @Nullable Object... aArgs) Format the given text usingMessageFormatwith the default format locale.static @Nullable StringgetFormattedText(@NonNull Locale aDisplayLocale, @Nullable String sText, @Nullable Object... aArgs) Format the given text usingMessageFormatwith the specified locale.
-
Method Details
-
getFormattedText
Format the given text usingMessageFormatwith the default format locale. If no arguments are provided, the text is returned unchanged.- Parameters:
sText- The message pattern to format. May benull.aArgs- The arguments to be substituted into the pattern. May benull.- Returns:
- The formatted text, or
nullif the input text isnull.
-
getFormattedText
public static @Nullable String getFormattedText(@NonNull Locale aDisplayLocale, @Nullable String sText, @Nullable Object... aArgs) Format the given text usingMessageFormatwith the specified locale. If no arguments are provided, the text is returned unchanged.- Parameters:
aDisplayLocale- The locale to use for formatting. May not benull.sText- The message pattern to format. May benull.aArgs- The arguments to be substituted into the pattern. May benull.- Returns:
- The formatted text, or
nullif the input text isnull.
-