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?