Currency format using Apex:outputText is very easy, The advantage of using Apex:outputText for showing a currency is it always respects the currency of the current user.
Below is one example, where we will see how we can format a number into a currency. CurrentFormatController is an apex class.
1 2 3 4 5 6 |
public class CurrentFormatController{ public Decimal amount {get;set;} public CurrentFormatController(){ amount = 799.99; } } |
Visualforce code for our example is kept very simple, It will look like the below
1 2 3 4 5 |
<apex:page controller="CurrentFormatController"> <apex:outputText value="{0, number, currency}"> <apex:param value="{!amount}" /> </apex:outputText> </apex:page> |
The final output of the above code will be
$799.99
Showing dollar currency symbol as per the current user, If user has different currecny it will show accordingly.