trying to return integer in reverse (without recursion)

i’m trying to print the reverse of a given integer. the function must take in an integer and return an integer (w/o recursion or printing each number as a string individually). this is what I’ve got but it’s not working:

class Solution {
public int reverse(int x) 
{
    String numStr = "";
    while (x > 0)
    {  
        numStr = numStr + Integer.toString(x % 10);
        x /= 10;
    }
    return Integer.parseInt(numStr);
}
}

i’m getting a runtime error for my return statement. Any help or advice is greatly appreciated!