formatNumber"

From Documentation
(Created page with "{{ZUMLReferencePageHeader}} The default method: <source lang="java"> String formatNumber (Object number, String pattern); </source> :i.e., <javadoc method="formatNumber (java....")
 
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{ZUMLReferencePageHeader}}
 
{{ZUMLReferencePageHeader}}
 +
{{versionSince|6.0.1}}
  
 
The default method:
 
The default method:
  
 
<source lang="java">
 
<source lang="java">
String formatNumber (Object number, String pattern);
+
String formatNumber(Object number, String pattern);
 
</source>
 
</source>
  
:i.e., <javadoc method="formatNumber (java.lang.Object, java.lang.String)">org.zkoss.xel.fn.CommonFns</javadoc>
+
:i.e., <javadoc method="formatNumber(java.lang.Object, java.lang.String)">org.zkoss.xel.fn.CommonFns</javadoc>
  
 
Formats a number (Integer, BigDecimal...) into a string with the given pattern.
 
Formats a number (Integer, BigDecimal...) into a string with the given pattern.
  
There is another extended built in function,  
+
For example,
 
+
<source lang="xml">
<source lang="java">
+
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
String formatNumber (Object number, String pattern, Locale locale);
+
<zk>
 +
    <label value="${c:formatNumber(2332315231, '$ ###,###,###.00')}" />
 +
</zk>
 
</source>
 
</source>
  
:i.e., <javadoc method="formatNumber (java.lang.Object, java.lang.String, java.util.Locale)">org.zkoss.xel.fn.CommonFns</javadoc>
+
There is another extended built-in function, not declared in taglib: <javadoc method="formatNumber(java.lang.Object, java.lang.String, java.util.Locale)">org.zkoss.xel.fn.CommonFns</javadoc>.
 
 
Formats a number (Integer, BigDecimal...) into a string with the given pattern and locale.
 
  
You can define a method to use this function by [http://books.zkoss.org/wiki/ZUML_Reference/ZUML/Processing_Instructions/xel-method xel-method]
+
You can call it by [[ZUML%20Reference/EL%20Expressions/Static%20Fields%20and%20Methods| EL]] or declaring a [[ZUML_Reference/ZUML/Processing_Instructions/xel-method| xel-method]].
  
  
 
'''Parameters:'''
 
'''Parameters:'''
In both default and extended function:
+
In both default and extended functions:
 
*number - the Number to format
 
*number - the Number to format
 
*pattern - the pattern to apply
 
*pattern - the pattern to apply
Line 31: Line 32:
 
*locale - the locale to apply
 
*locale - the locale to apply
  
=Version History=
 
{{LastUpdated}}
 
{| border='1px' | width="100%"
 
! Version !! Date !! Content
 
|-
 
| 6.0.1
 
| &nbsp;
 
| &nbsp;
 
|}
 
  
 
{{ZUMLReferencePageFooter}}
 
{{ZUMLReferencePageFooter}}

Latest revision as of 08:42, 8 August 2023

Since 6.0.1

The default method:

String formatNumber(Object number, String pattern);
i.e., CommonFns.formatNumber(Object, String)

Formats a number (Integer, BigDecimal...) into a string with the given pattern.

For example,

<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
<zk>
    <label value="${c:formatNumber(2332315231, '$ ###,###,###.00')}" />
</zk>

There is another extended built-in function, not declared in taglib: CommonFns.formatNumber(Object, String, Locale).

You can call it by EL or declaring a xel-method.


Parameters: In both default and extended functions:

  • number - the Number to format
  • pattern - the pattern to apply

In extended function only:

  • locale - the locale to apply



Last Update : 2023/08/08

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.