Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
hari azmeera 8

# convert integer to string, string to integer

Mahesh D
Hi Hari,

valueOf(stringToInteger)

Returns an Integer that contains the value of the specified String. As in Java, the String is interpreted as representing a signed decimal integer.

Signature
public static Integer valueOf(String stringToInteger)

Parameters
stringToInteger
Type: String

Return Value
Type: Integer

Example:

`Integer myInt = Integer.valueOf('123');`

valueOf(integerToConvert)
Returns a String that represents the specified Integer.

Signature
public static String valueOf(Integer integerToConvert)

Parameters
integerToConvert
Type: Integer

Return Value
Type: String

Example

```Integer myInteger = 22;
String sInteger = String.valueOf(myInteger);
System.assertEquals('22', sInteger);```

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_integer.htm

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_string.htm#apex_System_String_valueOf_5

Please do let me know if it helps you.

Regards,
Mahesh

Suraj Tripathi 47
Hi Hari,
You can use this to Convert From Integer To String:-
String convertIntegerToString= String.valueOf(IntegerValue);

For String To Integer You may use this one:-
`Integer convertStringToInteger= Integer.valueOf('SomeStringValue');`
If you find your Solution then mark this as the best answer.

Thank you!

Regards
Suraj Tripathi