function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Marcelo AgostinhoMarcelo Agostinho 

Formating Double to two Decimal Places

Hello...

 

Im having one problem trying to convert values to show on my visualforce page:

 

How can i convert the following number to have to decimal places...

 

Sometimes i ll have a number like. 42.0 other time i ll have a number like 37.3333333333333

 

Im trying to solve it using what i found here. but the problem is always the same.

 

Tks for everything

Best Answer chosen by Admin (Salesforce Developers) 
Cory CowgillCory Cowgill

What visualforce tag are you using?

 

<apex:outputText> or <apex:outputField>?

 

If you are using the <apex:outputText> I would review the documenation here. Look at the outputText field in the Standard Component References section:

 

http://www.salesforce.com/us/developer/docs/pages/index.htm

 

With outputText can format numbers like:

<apex:outputText value="{0, number, 000,000.00}">
       <apex:param value="{!Account.AnnualRevenue}" />
 </apex:outputText>

All Answers

Cory CowgillCory Cowgill

What visualforce tag are you using?

 

<apex:outputText> or <apex:outputField>?

 

If you are using the <apex:outputText> I would review the documenation here. Look at the outputText field in the Standard Component References section:

 

http://www.salesforce.com/us/developer/docs/pages/index.htm

 

With outputText can format numbers like:

<apex:outputText value="{0, number, 000,000.00}">
       <apex:param value="{!Account.AnnualRevenue}" />
 </apex:outputText>

This was selected as the best answer
Marcelo AgostinhoMarcelo Agostinho

Very Tks!!!

Its work perfectly for me!

RajgottipoluRajgottipolu

Hi People,

 

Is there any way i can use it for input fields too?

 

Here is the problem im having:

 

I enter a decimal value 10 for an inputfield and click next to go to another block. and when i click back..the input field shows '10.0' instead of '10.00' even though im using setscale(2). any thoughts on this?

pumbaapumbaa

Thanks!! that helps me.