### Question:
TtmlHelpers { public static long toTime(String expr) { Pattern p = Pattern.compile("(-?)([0-9][0-9]):([0-9][0-9]):([0-9][0-9])([\\.:][0-9][0-9]?[0-9]?)?"); Matcher m = p.matcher(expr); if (m.matches()) { String minus = m.group(1); String hours = m.group(2); String minutes = m.group(3); String seconds = m.group(4); String fraction = m.group(5); if (fraction == null) { fraction = ".000"; } fraction = fraction.replace(":", "."); long ms = Long.parseLong(hours) * 60 * 60 * 1000; ms += Long.parseLong(minutes) * 60 * 1000; ms += Long.parseLong(seconds) * 1000; if (fraction.contains(":")) { ms += Double.parseDouble("0" + fraction.replace(":", ".")) * 40 * 1000; } else { ms += Double.parseDouble("0" + fraction) * 1000; } return ms * ("-".equals(minus) ? -1 : 1); } else { throw new RuntimeException("Cannot match '" + expr + "' to time expression"); } }  static void main(String[] args); static String[] getAllNamespaces(Document doc); static String toTimeExpression(long ms); static String toTimeExpression(long ms, int frames); static long toTime(String expr); static void pretty(Document document, OutputStream outputStream, int indent); static long getStartTime(Node p); static long getEndTime(Node p); static void deepCopyDocument(Document ttml, File target); static final String SMPTE_TT_NAMESPACE; static final String TTML_NAMESPACE; static final NamespaceContext NAMESPACE_CONTEXT; }### Answer:
@Test public void testToTime() throws Exception { Assert.assertEquals(-3599000, toTime("-00:59:59.000")); Assert.assertEquals(3599000, toTime("00:59:59.000")); }