DateUtils { public static String trimToMillis(String toParse) { Matcher matcher = MILLIS_PATTERN.matcher(toParse); if (matcher.find()) { toParse = matcher.group(1); if (matcher.group(2) != null) toParse += matcher.group(2); } return toParse; }  static String trimToMillis(String toParse); static String trimTZ(String toParse); static String findTZ(String toParse);  }
@Test public void testTrimsToMillisWithTimezone() { assertEquals("NO_MILLISZ", DateUtils.trimToMillis("NO_MILLISZ")); assertEquals("NO_MILLIS.1Z", DateUtils.trimToMillis("NO_MILLIS.1Z")); assertEquals("NO_MILLIS.12Z", DateUtils.trimToMillis("NO_MILLIS.12Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.123Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.1234Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.123456Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.1234567Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345689Z")); assertEquals("NO_MILLIS.123Z", DateUtils.trimToMillis("NO_MILLIS.12345690123345678Z")); }
@Test public void testTrimsToMillisNoTimezone() { assertEquals("NO_MILLIS", DateUtils.trimToMillis("NO_MILLIS")); assertEquals("NO_MILLIS.1", DateUtils.trimToMillis("NO_MILLIS.1")); assertEquals("NO_MILLIS.12", DateUtils.trimToMillis("NO_MILLIS.12")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.1234")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.123456")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.1234567")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345689")); assertEquals("NO_MILLIS.123", DateUtils.trimToMillis("NO_MILLIS.12345690123345678")); }