[OmniFaces utilities] The
formatThousandsUnit() formats the given number to nearest 10n (rounded to thousands), suffixed with a space, the metric unit prefix (k, M, G, T, P or E) and the given unit, rounding half up with a precision of 3 digits, whereafter trailing zeroes in fraction part are stripped. 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.The given unit used in the format is of type B for Bytes, W for Watt, etc. If the unit is null, then this method will behave exactly as described in #formatThousands(Number).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:
// 1.1 FOO
#{of:formatThousandsUnit(1.1, "FOO")}
// 11.1 FOO
#{of:formatThousandsUnit(11.1, "FOO")}
// 111.1 FOO
#{of:formatThousandsUnit(111.1, "FOO")}
// 1.11 k FOO
#{of:formatThousandsUnit(1111.1, "FOO")}
// 11.1 k FOO
#{of:formatThousandsUnit(11111.1, "FOO")}
// 111 k FOO
#{of:formatThousandsUnit(111111.1, "FOO")}
// 1.11 M FOO
#{of:formatThousandsUnit(1111111.1, "FOO")}
// 11.1 M FOO
#{of:formatThousandsUnit(11111111.1, "FOO")}
// 111 M FOO
#{of:formatThousandsUnit(111111111.1, "FOO")}
// 1.11 G FOO
#{of:formatThousandsUnit(1111111111.1, "FOO")}
// 11.1 G FOO
#{of:formatThousandsUnit(11111111111.1, "FOO")}
// 111 G FOO
#{of:formatThousandsUnit(111111111111.1, "FOO")}
// 1.11 T FOO
#{of:formatThousandsUnit(1111111111111.1, "FOO")}
// 11.1 T FOO
#{of:formatThousandsUnit(11111111111111.1, "FOO")}
// 111 T FOO
#{of:formatThousandsUnit(111111111111111.1, "FOO")}
// 1.11 P FOO
#{of:formatThousandsUnit(1111111111111111.1, "FOO")}
// 11.1 P FOO
#{of:formatThousandsUnit(11111111111111111.1, "FOO")}
// 111 P FOO
#{of:formatThousandsUnit(111111111111111111.1, "FOO")}
// 1.11 E FOO
#{of:formatThousandsUnit(1111111111111111111.1, "FOO")}
// 1.111111111111111E19 FOO
#{of:formatThousandsUnit(11111111111111111111.1, "FOO")}
// java.util.UnknownFormatConversionException
#{of:formatThousandsUnit(111111111111111111111.1, "FOO")}







JSF 2 Tutorials at www.mkyong.com
JavaServer Faces (JSF) Tutorial 

















Niciun comentariu :
Trimiteți un comentariu