If the size of an int (-2^31) isn't big enough you may need to consider using primitive type long or Long object when converting from a string. In this example we will show how to convert a string to a primitive double, object Double and vise versa. Just like when you change a string to an int you will need to handle NumberFormatException in the instance your string has both numeric and characters. If you are stuck with a chars among digits you could use a regex to obtain all numerals.