public final class Numbers
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
formatBytes(java.lang.Long bytes)
Format the given bytes to nearest 10n with IEC binary unit (KiB, MiB, etc) with rounding precision of
1 fraction.
|
static java.lang.String |
formatCurrency(java.lang.Number number,
java.lang.String currencySymbol)
Format the given number as currency with the given symbol.
|
static java.lang.String |
formatNumber(java.lang.Number number,
java.lang.String pattern)
Format the given number in the given pattern.
|
static java.lang.String |
formatNumberDefault(java.lang.Number number)
Format the given number in the locale-default pattern.
|
static java.lang.String |
formatPercent(java.lang.Number number)
Format the given number as percentage.
|
public static java.lang.String formatBytes(java.lang.Long bytes)
Faces.getLocale()
.bytes
- The bytes to be formatted.public static java.lang.String formatCurrency(java.lang.Number number, java.lang.String currencySymbol)
title
attribute of an UI component, or the itemLabel
attribute of select item, or wherever you can't use the <f:convertNumber>
tag. The format
locale will be set to the one as obtained by Faces.getLocale()
.number
- The number to be formatted as currency.currencySymbol
- The currency symbol to be used.java.lang.NullPointerException
- When the currency symbol is null
.public static java.lang.String formatNumber(java.lang.Number number, java.lang.String pattern)
title
attribute of an UI component, or the itemLabel
attribute of select item, or
wherever you can't use the <f:convertNumber>
tag. The format locale will be set to the one as
obtained by Faces.getLocale()
.number
- The number to be formatted in the given pattern.pattern
- The pattern to format the given number in.java.lang.NullPointerException
- When the pattern is null
.public static java.lang.String formatNumberDefault(java.lang.Number number)
title
attribute of an UI component, or the itemLabel
attribute of select
item, or wherever you can't use the <f:convertNumber>
tag. The format locale will be set to
the one as obtained by Faces.getLocale()
.number
- The number to be formatted in the locale-default pattern.public static java.lang.String formatPercent(java.lang.Number number)
title
attribute of an UI component, or the itemLabel
attribute of select item, or wherever you can't use the <f:convertNumber>
tag. The format
locale will be set to the one as obtained by Faces.getLocale()
.number
- The number to be formatted as percentage.