### Question:
TimeIntervalParser { public static Long parse(String string) { int days = 0; int hours = 0; int minutes = 0; long seconds = 0; boolean parsed = false; string = StringHelper.clean(string); try { days = Integer.parseInt(StringHelper.getRegexpMatch("[0-9]+(?=\\s?([dD]ays?))", string)); parsed = true; } catch (Exception ignored) { } try { hours = Integer.parseInt(StringHelper.getRegexpMatch("[0-9]+(?=\\s?([hH]ours?|hrs?))", string)); parsed = true; } catch (Exception ignored) { } try { minutes = Integer.parseInt(StringHelper.getRegexpMatch("[0-9]+(?=\\s?([mM]inutes?|[Mm]ins?))", string)); parsed = true; } catch (Exception ignored) { } try { seconds = Long.parseLong(StringHelper.getRegexpMatch("[0-9]+(?=\\s?([sS]econds?|secs?))", string)); parsed = true; } catch (Exception ignored) { } if (parsed) { seconds += 86400 * days + 3600 * hours + 60 * minutes; } else { String hoursString = StringHelper.getRegexpMatch("\\d+(?=[hH])", string); String minutesString = StringHelper.getRegexpMatch("\\d+(?=([mM])|( Mins| minutes))", string); String secondsString = StringHelper.getRegexpMatch("\\d+(?=([sS])|( Seconds))", string); if (hoursString != null && !hoursString.isEmpty()) { seconds = 3600 * Integer.valueOf(hoursString); } if (minutesString != null && !minutesString.isEmpty()) { seconds += 60 * Integer.valueOf(minutesString); } if (secondsString != null && !secondsString.isEmpty()) { seconds += Integer.valueOf(secondsString); } if (seconds > 0) { return seconds; } return null; } return seconds; }  static Long parse(String string);  }### Answer:
@Test public void testParse() { assertEquals(250, TimeIntervalParser.parse("PT4M10S"), 0.1); assertEquals(9910, TimeIntervalParser.parse("PT2H45M10S"), 0.1); assertEquals(TimeUnit.MINUTES.toSeconds(20), TimeIntervalParser.parse(" Active Time:\n \n\t 20 mins\n minutes"), 0.1); assertEquals(TimeUnit.MINUTES.toSeconds(125), TimeIntervalParser.parse("the movie lasted 2 hours and 5 minutes"), 0.1); assertEquals(TimeUnit.MINUTES.toSeconds(260), TimeIntervalParser.parse("4 hrs 20 mins"), 0.1); assertEquals(TimeUnit.MINUTES.toSeconds(1463), TimeIntervalParser.parse("1 day 23 mins"), 0.1); assertEquals(TimeUnit.MINUTES.toSeconds(25), TimeIntervalParser.parse("25min"), 0.1); assertEquals(TimeUnit.MINUTES.toSeconds(490), TimeIntervalParser.parse("8hours 10min"), 0.1); assertEquals(TimeUnit.MINUTES.toSeconds(490), TimeIntervalParser.parse("8hours \n\n\n\t\t\t10min"), 0.1); }