1

If in an Apex class I set some decimal values like so:

public List<String> args = new String[] { '0', 'number', '#,###,###.##' };

public String getPrice() {
    Decimal amount = (lead.Price__c).setScale(2);
    return String.format(amount.format(), args);
}

It will return prices either like so: 1,234 or 1,234.5. How can I change my method to return cents so that it'll return 1,234.00 or 1,234.50? I tried the format in args, and I tried setting the scale to 2, and neither work.

Any help?

3
  • Nah, it doesn't really have the same implications as currency formatting. It might have been asked on SFSE, but not there.
    – Adrian Larson
    Aug 24, 2016 at 4:33
  • @vamsi, you marked it as duplicate of the wrong one. He is not asking to convert a string to a currency.
    – brovasi
    Aug 24, 2016 at 4:42
  • salesforce.stackexchange.com/questions/38520/… that's the one
    – brovasi
    Aug 24, 2016 at 4:43

0

Browse other questions tagged .