public final class Numbers extends Object
Collection of EL functions for number formatting: of:formatBytes()
, of:formatCurrency()
,
of:formatNumber()
, of:formatNumberDefault()
and of:formatPercent()
.
Modifier and Type | Method and Description |
---|---|
static String |
formatBytes(Long bytes)
Format the given bytes to nearest 10n with IEC binary unit (KiB, MiB, etc) with rounding precision of
1 fraction.
|
static String |
formatCurrency(Number number,
String currencySymbol)
Format the given number as currency with the given symbol.
|
static String |
formatNumber(Number number,
String pattern)
Format the given number in the given pattern.
|
static String |
formatNumberDefault(Number number)
Format the given number in the locale-default pattern.
|
static String |
formatPercent(Number number)
Format the given number as percentage.
|
public static String formatBytes(Long bytes)
Faces.getLocale()
.bytes
- The bytes to be formatted.public static String formatCurrency(Number number, 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.NullPointerException
- When the currency symbol is null
.public static String formatNumber(Number number, 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.NullPointerException
- When the pattern is null
.public static String formatNumberDefault(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 String formatPercent(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.Copyright © 2012–2015 OmniFaces. All rights reserved.