Monday, January 27, 2014

How to display the formatted number / date in Visualforce ? Which component should be used

How to display the formatted number / date in Visualforce ? Which component should be used

Use component “<apex:outputText>”.
Example : Format the number into currency.
<apex:outputtext value="{0, number, 000,000.00}">
   <apex:param value="{!valFromController}" />
</apex:outputtext>
OR
<apex:outputtext value="{0, number, ###,###.00}">
   <apex:param value="{!valFromController}" />
</apex:outputtext>
Read in Detail , here

Format                                   Input                                                    Output
{0, date, short}                     Sun Dec 15 07:00:11 GMT 2013      12/15/13
{0, date, medium}               Sun Dec 15 07:00:11 GMT 2013      Dec 15, 2013
{0, date, long}                       Sun Dec 15 07:00:11 GMT 2013      December 15, 2013
{0, date, full}                        Sun Dec 15 07:00:11 GMT 2013      Sunday, December 15, 2013
{0, date, yyyy-mm-dd hh:mm:ss a} Sun Dec 15 07:00:11 GMT 2013      2013-Dec-15 07:00:11 AM GMT
{0, number, integer}           123.456                                                 123
{0, number, currency}        123.456                                                 $123.46
{0, number, percent}          0.5                                                          50%
{0, number, 0000.0}           123.456                                                0123.5
{0, number, ####.#}          123.456                                                123.5
{0, number, 0.0000}           123.456                                                123.4560
{0, number, #.####}          123.456                                                123.456


1 comment:

  1. I am Having a Field value like this "1234-Test Value", Here I want to display the number part alone in the Template, How can I display this, do we have any other format??

    ReplyDelete