- 

Available since OmniFaces 1.2

Collection of EL functions for number formatting: of:formatBytes(), of:formatCurrency(), of:formatNumber(), of:formatNumberDefault(), of:formatPercent(), of:formatThousands() and of:formatThousandsUnit().

Feature request

If you know more useful methods/functions which you think should be added to this OmniFaces utility class so that everyone can benefit from a "standard" Faces utility library, feel free to post a feature request.

Demo

Format a given amount of bytes with IEC binary unit: 1023 B, 1.0 KiB, 488.3 KiB, 1.0 MiB

Format a number as currency using given currency symbol: $123.46

Format a number using given pattern: 123.46

Format a number using locale-default pattern: 123.457

Format a number using locale-default pattern of given locale: 123,457

Format a number as percent: 12%

Format a number as thousands: 1k, 1.01k, 9.99k, 10M

Format a number as thousands with unit: 1 kW, 1.01 kW, 9.99 kW, 10 MW

Demo source code
<p>
    Format a given amount of bytes with IEC binary unit: 
    #{of:formatBytes(1023)}, #{of:formatBytes(1024)}, #{of:formatBytes(500000)}, #{of:formatBytes(1048576)}
</p>
<p>
    Format a number as currency using given currency symbol:
    #{of:formatCurrency(123.4567, '$')}
</p>
<p>
    Format a number using given pattern:
    #{of:formatNumber(123.4567, '#.00')}
</p>
<p>
    Format a number using locale-default pattern:
    #{of:formatNumberDefault(123.4567)}
</p>
<p>
    Format a number using locale-default pattern of given locale:
    #{of:formatNumberDefaultForLocale(123.4567, 'nl_NL')}
</p>
<p>
    Format a number as percent:
    #{of:formatPercent(0.123)}
</p>
<p>
    Format a number as thousands:
    #{of:formatThousands(1004)}, #{of:formatThousands(1005)}, #{of:formatThousands(9994)}, #{of:formatThousands(9995000)}
</p>
<p>
    Format a number as thousands with unit:
    #{of:formatThousandsUnit(1004, 'W')}, #{of:formatThousandsUnit(1005, 'W')}, #{of:formatThousandsUnit(9994, 'W')}, #{of:formatThousandsUnit(9995000, 'W')}
</p>