You need to sign in to do that
Don't have an account?
Anu Raj.ax1269
Replacing string value
Hi
I want to replace the value of a string. This is a integer but saved in string. Eg: i am getting the value as 123.345 the i need to get the value as 123 only. I want to replace value after . with '' but the issue is i don't know how many decimal place is coming after point. Please help me to solve this issue.
Thanks
Anu
Hai thanks gays..
I found the solution
All Answers
Hi anu
This may helpful to you
Decimal d=123.345;
integer i=Integer.valueOf(d);
String s=String.valueOf(i);
System.Debug('-------->'+s);
if it helpful plz make solution as acceptable for others it may benfit
string stringval = '123.345';
decimal decimalValue = decimal.valueof(stringval);
Integer integerValue = decimalValue.intValue();
string newval = string.valueof(integerValue) + '. any number or letter';
system.debug(newval);
Thanks, you both are right and I have done the same but I need to do this by using string only not by converting into integer then to string again. Do anybody have any idea.
Hai thanks gays..
I found the solution
string a = '123.456';
list<string> split_a = a.split('\\.');
system.debug(split_a[0]);