You need to sign in to do that
Don't have an account?
Balwant_Singh
How To Format String
Hi All,
My problem is that. I have a double value in my controller and i converted it in to String like as;
Double value = 0.5268056142435206;
String str = String.ValueOf(value );
Now when i print this on page its comes like 0.5268056142435206 as i expected.
But my requirement is to print something like 0.52 on screen.
How i will achieve this?
Thanks in advance..
You can use substring() funtion in order to get the desired number of characters from the sequence.
For 0.52, I think you have 4 characters. So this should work for you str.substring(0,4) where 0 is the start index and 4 is the end index.
Hoping this will work.
Apex:outputText supports formatting. See
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#StartTopic=Content/pages_compref_outputText.htm