You can do it in few ways:
1
str = str.substring(str.indexOf("=") + 1, str.indexOf("ms")).trim();
int result = Integer.valueOf(str);
2
str = str.replace("time=", "").replace("ms", "").trim();
int result = Integer.valueOf(str);
3
Pattern pattern = Pattern.compile("\\d+");
Matcher matcher = pattern.matcher(output.toString());
matcher.find();
String result = matcher.group();
int result = Integer.valueOf(str);
4
str = str.replaceAll("\\D+","");