0

I have a currency field that is defined as 16,2 for the length and decimal places. On my VF page, I refer to the field below, and I get 4 decimal places. Why does that happen, and how do I resolve this?

Thanks!

                     <apex:column >
                      <apex:facet name="header"> 
                      {!$ObjectType.myobj__c.fields.myfield__c.Label}
                      </apex:facet>
                     {!f.myfield__c}
                    </apex:column>

1 Answer 1

3

The database will hold more than the precision and scale defined on the field. If it was entered with 4 decimals the database stores 4 decimals

Using the apex:outputfield instead of simply if displaying the merge variable will get you the formatting defined for the field.

You could also use java message format like so

<apex:outputText value="{0,number,###,###.00}">
      <apex:param value="{!youfield}"/>
</apex:outputText>
2
  • oh, i didn't know that the field would store additional precision. I can't use apex:output field, because i'm running into state issues on the page. Commented Nov 8, 2016 at 6:34
  • Then fix the state issues or use java messaging to format the output
    – Eric
    Commented Nov 8, 2016 at 6:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .