I have a custom field who's type is number, with format: 18 digit, 0 decimal places. However, when I output it using <apex:outputfield value="soBject__c.Number__c" /> for example, it displays: 18.0 dispite the fact that it's 0 decimal places in the number?

Is there anyway to hide the .0 ? Or do I just need to convert it to a string?


I've found that by far the easiest/simplest way to achieve this is to just use the FLOOR() Visualforce function:

<apex:outputText value="{!FLOOR(sObject.Number__c)}"/>
  • This works great when the scale is 0 (your case). – DerekLansing Sep 12 '12 at 4:34
  • Yeah, you don't want to use it for situations where you want to keep your decimal part (or round correctly), but when scale is 0 and you don't want the .0 showing, it's the option with the cleanest markup IMO. – Matt Lacey Sep 12 '12 at 4:38
  • I agree that this is much simpler than the MessageFormat, and therefore better IMO. This question only asks specifically about whole numbers with 0 decimal places which this method covers. – Peter Knolle Sep 12 '12 at 10:33

would formatting do the trick?

   <apex:outputText value="{0,number,#,##0}">$    
       <apex:param value="{!soBject__c.Number__c}"/>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.