[OmniFaces utilities] The
formatThousands()
formats the given number to nearest 10n (rounded to thousands), immediately suffixed (without space) with metric unit (k, M, G, T, P or E), rounding half up with a precision of 3 digits, whereafter trailing zeroes in fraction part are stripped. Numbers lower than thousand are not affected. The format locale will be set to the one as obtained by Faces#getLocale()
. If the value is null
, NaN
or infinity, then this will return null
.This function is available from OmniFaces 2.3, but in OmniFaces 2.4, the incorrectly trimmed trailing zeroes from non-fractional integer numbers was fixed and now also supports cutting down fractions of values lower than thousand.
Function:
Usage:
// 9.99 k
#{of:formatThousandsUnit(9994)}
// 10 M
#{of:formatThousandsUnit(9995000)}
// 532 k
#{of:formatThousandsUnit(532230.6483)}
Niciun comentariu :
Trimiteți un comentariu