DateTimeTools { public static int processRuntime(final String runtime) { if (StringUtils.isBlank(runtime)) { return -1; } int returnValue = (int) NumberUtils.toFloat(runtime, -1f); if (returnValue < 0) { Pattern hrmnPattern = Pattern.compile("(?i)(\\d+)(\\D*)(\\d*)(.*?)"); Matcher matcher = hrmnPattern.matcher(runtime); if (matcher.find()) { int first = NumberUtils.toInt(matcher.group(1), -1); String divide = matcher.group(2); int second = NumberUtils.toInt(matcher.group(3), -1); if (first > -1 && second > -1) { returnValue = (first > -1 ? first * 60 : 0) + (second > -1 ? second : 0); } else if (isNotValidString(divide)) { returnValue = first; } else if (second > -1 && isValidString(divide)) { if (divide.toLowerCase().contains("h")) { returnValue = first * 60; } else { returnValue = first; } } } } return returnValue; } private  DateTimeTools(); static String getDateFormatString(); static String getDateFormatLongString(); static SimpleDateFormat getDateFormat(); static SimpleDateFormat getDateFormatLong(); static String convertDateToString(Date convertDate); static String convertDateToString(DateTime convertDate); static String convertDateToString(Date convertDate, final String dateFormat); static String convertDateToString(DateTime convertDate, final String dateFormat); static String formatDuration(int duration); static int processRuntime(final String runtime); static String parseDateToString(String dateToParse); static Date parseStringToDate(final String dateToParse); static int extractYear(String date);  }
@Test public void testProcessRuntime() { LOG.info("processRuntime"); String runtime = "1h 32m"; int expResult = 92; int result = DateTimeTools.processRuntime(runtime); assertEquals(expResult, result); }