You can use this way with String::matches like this :
String userid = "user001";
int int_userid = userid.matches("\\d+") ? Integer.parseInt(userid) : 0;
You ca also use -?\d+ for both positive and negative values :
int int_userid = userid.matches("-?\\d+") ? Integer.parseInt(userid) : 0;