Decimal to Currency format using apex in Salesforce

Sample Code:

Decimal a = 14862.00;
system.debug('Currency is ' + (a.format().contains('.')?a.format():(a.format()+'.00')));

a = 14862.05;
system.debug('Currency is ' + (a.format().contains('.')?a.format():(a.format()+'.00')));

Output:


Cheers!!!

No comments:

Post a Comment