How do format output text to show only whole numbers and not decimals along with it in Vf page

Prady picture Prady · Feb 11, 2012 · Viewed 8.1k times · Source

I want to display a field in a object to show just the whole number/integer value. This field has decimal values in the structure but for i need to show the integer value for this VF page only.

 <apex:pageBlockSectionItem >
                    <apex:outputLabel value="# Connections" for="Connections"/>
                    <apex:outputText id="Connections" value="{!Event__c.Total_Connections__c}" />         
                </apex:pageBlockSectionItem>

No of connections has to be shown as whole number.

thanks

Answer

mmix picture mmix · Feb 11, 2012

You can use parametrized output with formating, for example:

<apex:outputText id="Connections" value="{0, number, integer}">
    <apex:param value="{!Event__c.Total_Connections__c}" />
</apex:outputText>

For more detail about all the formating options, check Java's MessageFormat, the same formating is used for <apex:outputText>