- 

Available since OmniFaces 1.2

Collection of EL functions for number formatting: o:formatBytes(), o:formatCurrency(), o:formatNumber(), o:formatNumberDefault(), o:formatPercent(), o:formatThousands() and o: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: 
    #{o:formatBytes(1023)}, #{o:formatBytes(1024)}, #{o:formatBytes(500000)}, #{o:formatBytes(1048576)}
</p>
<p>
    Format a number as currency using given currency symbol:
    #{o:formatCurrency(123.4567, '$')}
</p>
<p>
    Format a number using given pattern:
    #{o:formatNumber(123.4567, '#.00')}
</p>
<p>
    Format a number using locale-default pattern:
    #{o:formatNumberDefault(123.4567)}
</p>
<p>
    Format a number using locale-default pattern of given locale:
    #{o:formatNumberDefaultForLocale(123.4567, 'nl_NL')}
</p>
<p>
    Format a number as percent:
    #{o:formatPercent(0.123)}
</p>
<p>
    Format a number as thousands:
    #{o:formatThousands(1004)}, #{o:formatThousands(1005)}, #{o:formatThousands(9994)}, #{o:formatThousands(9995000)}
</p>
<p>
    Format a number as thousands with unit:
    #{o:formatThousandsUnit(1004, 'W')}, #{o:formatThousandsUnit(1005, 'W')}, #{o:formatThousandsUnit(9994, 'W')}, #{o:formatThousandsUnit(9995000, 'W')}
</p>