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
nsattishnsattish 

Remove trailing zero with decimal format for apex:inputField

How to remove trailing zero with decimal format for <apex:inputField>  and <apex:outputField>

Field Definition - Decimal - (10,5) - Five Decimal precision

Example :

Value : 5.01 - SFDC stores and displayed as 5.01000. I need to remove the trailing zeros. Actual value should be 5.01

PremanathPremanath

Hi,

 

 Use Some String Methods like this way

 

Decimal d= 1.01000;
String s=String.valueOf(d);
Integer i=s.indexOf('.');
String str=s.substring(0,i+3);
Decimal dec=Decimal.valueOf(str);
System.Debug('------------'+dec);

 

 

prem

Victor GatnickiVictor Gatnicki

To remove trailing zeros from a Decimal type just using the format method

decimal val = 1.2000;
string temp = val.format();