I want to replace the value of a string. This is an 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.
You can use
String myString = '123.123435';
String st = myString.substring(0, myString.indexOf('.') );
System.debug(st);
One easy way is to convert it first into a decimal number and then convert the decimal into an integer.
String myString = '123.123435';
Decimal myDecimal = Decimal.valueOf(myString);
Integer myInteger = Integer.valueOf(myDecimal);
System.debug(myInteger);