@Immutable public final class LocaleFormatter extends Object
Modifier and Type | Method and Description |
---|---|
static String |
getFormatted(BigDecimal aValue,
int nFractionDigits,
Locale aDisplayLocale)
Format the passed value according to the rules specified by the given
locale.
|
static String |
getFormatted(BigDecimal aValue,
Locale aDisplayLocale)
Format the passed value according to the rules specified by the given
locale.
|
static String |
getFormatted(BigInteger aValue,
Locale aDisplayLocale)
Format the passed value according to the rules specified by the given
locale.
|
static String |
getFormatted(double dValue,
Locale aDisplayLocale)
Format the passed value according to the rules specified by the given
locale.
|
static String |
getFormatted(int nValue,
Locale aDisplayLocale)
Format the passed value according to the rules specified by the given
locale.
|
static String |
getFormatted(long nValue,
Locale aDisplayLocale)
Format the passed value according to the rules specified by the given
locale.
|
static String |
getFormattedPercent(double dValue,
int nFractionDigits,
Locale aDisplayLocale)
Format the given value as percentage.
|
static String |
getFormattedPercent(double dValue,
Locale aDisplayLocale)
Format the given value as percentage.
|
static String |
getFormattedWithAllFractionDigits(BigDecimal aValue,
Locale aDisplayLocale)
Format the passed value according to the rules specified by the given
locale.
|
@Nonnull public static String getFormatted(double dValue, @Nonnull Locale aDisplayLocale)
Double.toString(double)
that are displayed to
the user should instead use this method.dValue
- The value to be formatted.aDisplayLocale
- The locale to be used. May not be null
.@Nonnull public static String getFormatted(int nValue, @Nonnull Locale aDisplayLocale)
Integer.toString(int)
that are displayed to
the user should instead use this method.nValue
- The value to be formatted.aDisplayLocale
- The locale to be used. May not be null
.@Nonnull public static String getFormatted(long nValue, @Nonnull Locale aDisplayLocale)
Long.toString(long)
that are displayed to the
user should instead use this method.nValue
- The value to be formatted.aDisplayLocale
- The locale to be used. May not be null
.@Nonnull public static String getFormatted(@Nonnull BigInteger aValue, @Nonnull Locale aDisplayLocale)
BigInteger.toString()
that are displayed to
the user should instead use this method.aValue
- The value to be formatted. May not be null
.aDisplayLocale
- The locale to be used. May not be null
.@Nonnull public static String getFormatted(@Nonnull BigDecimal aValue, @Nonnull Locale aDisplayLocale)
BigDecimal.toString()
that are displayed to
the user should instead use this method. By default a maximum of 3 fraction
digits are shown.aValue
- The value to be formatted. May not be null
.aDisplayLocale
- The locale to be used. May not be null
.@Nonnull public static String getFormatted(@Nonnull BigDecimal aValue, @Nonnegative int nFractionDigits, @Nonnull Locale aDisplayLocale)
aValue
- The value to be formatted. May not be null
.nFractionDigits
- The number of fractional digits to use. Must be ≥ 0.aDisplayLocale
- The locale to be used. May not be null
.@Nonnull public static String getFormattedWithAllFractionDigits(@Nonnull BigDecimal aValue, @Nonnull Locale aDisplayLocale)
aValue
- The value to be formatted. May not be null
.aDisplayLocale
- The locale to be used. May not be null
.@Nonnull public static String getFormattedPercent(double dValue, @Nonnull Locale aDisplayLocale)
dValue
- The value to be used. E.g. "0.125" will result in something like
"12.5%"aDisplayLocale
- The locale to use.null
formatted string.@Nonnull public static String getFormattedPercent(double dValue, @Nonnegative int nFractionDigits, @Nonnull Locale aDisplayLocale)
dValue
- The value to be used. E.g. "0.125" will result in something like
"12.5%"nFractionDigits
- The number of fractional digits to use. Must be ≥ 0.aDisplayLocale
- The locale to use.null
formatted string.Copyright © 2014–2019 Philip Helger. All rights reserved.