Optimizing this question relating to parsing string to number?

Had a phone screen about this problem:
"Create a function that accepts a String input and spits out an integer" <-basically implementing ParseInt.

My solution was something like(removed some error checking for clarity). Just want to get some opinion on optimizing this or is this it? We ran out of time and i did get the "positive" scenario running correctly (i think negative wouldve worked too). I did miss an error checking part and i didn't account for ascii code conversion (he gave me a hint when the initial run of my code returned a weird number). Please excuse any syntax errors since i typed from memory

public int returnInteger (String numberString) {
  
	
	if (numberString == null) {
	    throw someException();
	}
  boolean isNegative = false;
	int result = 0;
	char[] charArray = numberString.toCharArray();
	
	for (int x=0; x < charArray.length(); x++) {
		if ( (int) charArray[x] <= 48 ||  (int) charArray[x] >= 57) {
		   throw someException();
		}
	}
		
	if (charArray[0] == '-') {
	     isNegative = true;
	}
	
	for ( int x =0; x < numberString.length(); x++) {
	     if (isNegative && x != 0) {
		      result = result + ((int) (charArray[x] + '0') ) * Math.pow(10,numberString.length()  - x -1)
		 
		 } else if (!isNegative){
		      result = result + ((int) (charArray[x] + '0') ) *Math.pow(10,numberString.length()  - x -1)
		 }		
	}
return result;
}
Comments (1)