@Test public void testMathParse() { long runtime = 50L * 1000L; TimeParser timeParser = new TimeParser(runtime); Assert.assertEquals(runtime, timeParser.parseRuntime("runtime")); long expected = runtime + TimeUnit.DAYS.toMillis(1) - TimeUnit.HOURS.toMillis(2) + TimeUnit.MINUTES.toMillis(3) - TimeUnit.SECONDS.toMillis(4); Assert.assertEquals(expected, timeParser.parseRuntime(" runtime + 1d-2h+3m - 4s ")); Assert.assertEquals(TimeUnit.MINUTES.toMillis(5), timeParser.parseRuntime("5m")); Assert.assertEquals(TimeUnit.SECONDS.toMillis(5), timeParser.parseRuntime("5s")); Assert.assertEquals(TimeUnit.HOURS.toMillis(5), timeParser.parseRuntime("5h")); Assert.assertEquals(TimeUnit.DAYS.toMillis(5), timeParser.parseRuntime("5d")); Assert.assertEquals(TimeUnit.DAYS.toMillis(5), timeParser.parseRuntime("+5d")); Assert.assertEquals(0 - TimeUnit.DAYS.toMillis(5), timeParser.parseRuntime("-5d")); }
public long parseRuntime(String str) { MathNode mathNode = parseExpression(str); return mathNode.evaluate(); }
TimeParser { public long parseRuntime(String str) { MathNode mathNode = parseExpression(str); return mathNode.evaluate(); } }
TimeParser { public long parseRuntime(String str) { MathNode mathNode = parseExpression(str); return mathNode.evaluate(); } TimeParser(long runtime); }
TimeParser { public long parseRuntime(String str) { MathNode mathNode = parseExpression(str); return mathNode.evaluate(); } TimeParser(long runtime); long parseRuntime(String str); static long parseDuration(String durationStr); }
TimeParser { public long parseRuntime(String str) { MathNode mathNode = parseExpression(str); return mathNode.evaluate(); } TimeParser(long runtime); long parseRuntime(String str); static long parseDuration(String durationStr);  }