How to get the currency symbol in Visualforce page?

How to get the currency symbol in Visualforce page?

Use <apex:outputField/> to show the currency symbol, instead of using <apex:outputText/>.
Sample Code:


Visualforce page:

<apex:page controller=”Sample”>
    <apex:pageblock >
        <apex:pageBlockTable value=”{!OpptyList}” var=”O”>
            <apex:column value=”{!O.Name}”/>
            <apex:column >
                <apex:outputField value=”{!O.Amount}”/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageblock>
</apex:page>

Apex Controller:

public class Sample {  
    public List<Opportunity> OpptyList {get;set;}
   
    public Sample() {
        OpptyList = [SELECT Name, Amount FROM Opportunity];
    }           
}

Output:

Leave a Reply