You need to sign in to do that
Don't have an account?

Print Double to 1 Decimal Place
Hello,
How can I print a Double on my VF page to one decimal place? Using format returns the number with 3 decimal points.
AT
You need to sign in to do that
Don't have an account?
Hello,
How can I print a Double on my VF page to one decimal place? Using format returns the number with 3 decimal points.
AT
This can be very easy depending on whether you need it to be a double on the page.
You can cast it to a string and use (''+myDouble).substring(0, string.indexOf('.')+1) which should take the string up to the char after the decimal point
I don't think there is an Apex equivalent of the Decimal Formatter to use.
Thanks Scoobie!
May be something like that
<apex:outputText value="{0, Number, #0.0}">
<apex:param value="{!Price__c}" />
</apex:outputText>
You can also use decimal for this function.
"3" indicates the amount of decimals to be used. System.RoundingMode defines how to round the double.
See the documentation on decimals for more information.
Rgrds,
Guy