org.omnifaces.el.functions
Class Numbers

java.lang.Object
  extended by org.omnifaces.el.functions.Numbers

public final class Numbers
extends java.lang.Object

Collection of EL functions for numbers.

Since:
1.2
Author:
Bauke Scholtz

Method Summary
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

formatBytes

public 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. For example: The format locale will be set to the one as obtained by Faces.getLocale().

Parameters:
bytes - The bytes to be formatted.
Returns:
The formatted bytes.

formatCurrency

public static java.lang.String formatCurrency(java.lang.Number number,
                                              java.lang.String currencySymbol)
Format the given number as currency with the given symbol. This is useful when you want to format numbers as currency in for example the 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().

Parameters:
number - The number to be formatted as currency.
currencySymbol - The currency symbol to be used.
Returns:
The number which is formatted as currency with the given symbol.
Throws:
java.lang.NullPointerException - When the currency symbol is null.

formatNumber

public static java.lang.String formatNumber(java.lang.Number number,
                                            java.lang.String pattern)
Format the given number in the given pattern. This is useful when you want to format numbers in for example the 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().

Parameters:
number - The number to be formatted in the given pattern.
pattern - The pattern to format the given number in.
Returns:
The number which is formatted in the given pattern.
Throws:
java.lang.NullPointerException - When the pattern is null.

formatNumberDefault

public static java.lang.String formatNumberDefault(java.lang.Number number)
Format the given number in the locale-default pattern. This is useful when you want to format numbers in for example the 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().

Parameters:
number - The number to be formatted in the locale-default pattern.
Returns:
The number which is formatted in the locale-default pattern.
Since:
1.3