4

I have these 3 fields that I'm calling in my visualforce component. They are all Currency(16, 2), but when I'm calling them in my component, they are being displayed as numbere 1111.00. is there a way to convert them to currency? i want 1,000.00.

                <table class="sub_section sectionHighlight"><tr>  
                        <td class="mysub_section_label " >a):</td>   <td class="sub_section_data" > {!c.a__c}</td> 
                        <td class="mysub_section_label " >b:</td>     <td class="sub_section_data"> {!c.b__c}</td> 
                        <td class="mysub_section_label " >c:</td>     <td class="sub_section_data " > {!c.c__c}</td>                      
                </tr></table>

3 Answers 3

8

Any reason why not to use an outputfield ? Doing so will automatically render field specifics according to user locale settings.

<apex:outputField value="{!c.a__c}"/>

Alternativly you could use the outputtext + formatting option:

<apex:outputText value="{0, number, 000,000.00}">
       <apex:param value="{!c.a__c}" />
</apex:outputText>

Visualforce has a lot of usefull components, have a look at the Standard Component Reference in the Visualforce Developer Guide

3
1

I found that Samuel's example, given a value of 0, will render 000,000.00.

I solved it using the currency operator from MessageFormat:

<apex:outputText value="{0, number, currency}">
  <apex:param value="{!c.a__c}" />
</apex:outputText>

Keep in mind, though: this solution prepends a dollar ($) sign to the output.

0

Try this code:

<apex:outputText label="NRR" value="{0,number}">
    {! Opportunity.CurrencyIsoCode} &nbsp;
    <apex:param value="{! Opportunity.NRR__c}" />
</apex:outputText>

This gives you the Currency (CurrencyIsoCode) as well as the value (in proper format) if it exists in the field value.

You must log in to answer this question.

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