My JSF Books/Videos My JSF Tutorials OmniFaces/JSF PPTs
JSF 2.3 Tutorial
JSF Caching Tutorial
JSF Navigation Tutorial
JSF Scopes Tutorial
JSF Page Author Beginner's Guide
OmniFaces 2.3 Tutorial Examples
OmniFaces 2.2 Tutorial Examples
JSF Events Tutorial
OmniFaces Callbacks Usages
JSF State Tutorial
JSF and Design Patterns
JSF 2.3 New Features (2.3-m04)
Introduction to OmniFaces
25+ Reasons to use OmniFaces in JSF
OmniFaces Validators
OmniFaces Converters
JSF Design Patterns
Mastering OmniFaces
Reusable and less-verbose JSF code

My JSF Resources ...

Java EE Guardian
Member of JCG Program
Member MVB DZone
Blog curated on ZEEF
OmniFaces is an utility library for JSF, including PrimeFaces, RichFaces, ICEfaces ...

[OmniFaces Utilities] - Find the right JSF OmniFaces 2 utilities methods/functions

Search on blog

Petition by Java EE Guardians

Twitter

duminică, 31 iulie 2016

[OmniFaces utilities (2.4)] Format the given number to nearest 10^n (rounded to thousands)


[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

JSF BOOKS COLLECTION

Postări populare

Follow by Email

Visitors Starting 4 September 2015

Locations of Site Visitors