1

If I return an object with a currency field, and I'm returning it from a controller. If I use an <apex:inputField>, the number is correctly formatted as 1,234.56.

However, if I use an <apex:inputHidden>, then the number will be returned as 1234.56 (without a thousand separator). I'd like to use that number to determine the current decimal separator dynamically (Javascript is used to perform some calculations).

Can I force the <apex:inputHidden> to format the number? Alternatively, how can I determine the current user's local settings for number separators in a controller? UserInfo.getLocale will get the locale. Is there an equivalent of DecimalFormat for Apex?

2

Instead of using apex:inputHidden, why don't you just use <span style="display: none"><apex:outputField id="someId" value="{!someRecord.CurrencyField__c}"/></span>? This way, the user won't see it, but you'll still get your formatting preferences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.