TimeResolver { public static Long resolveExpression(String subject) { Matcher m = expiryPattern.matcher(subject); if (m.find()) { String key = m.group(2); if (key.equals("")) key = defaultUnit; return Long.parseLong(m.group(1), 10) * timeMultipliers.get(key); } return -1L; }  static ZonedDateTime getExpiryDate(String expiresInString); static Long resolveExpression(String subject);  }
@Test public void testResolution() { Assert.assertEquals(TimeResolver.resolveExpression("30s"), Long.valueOf(30)); Assert.assertEquals(TimeResolver.resolveExpression("180s"), Long.valueOf(180)); Assert.assertEquals(TimeResolver.resolveExpression("1m"), Long.valueOf(60)); Assert.assertEquals(TimeResolver.resolveExpression("10m"), Long.valueOf(600)); Assert.assertEquals(TimeResolver.resolveExpression("2h"), Long.valueOf(7200)); }