SnapshotUtil { static long getSnapshotTimestamp(String snapshotName) { try { String suffix = snapshotName.substring(snapshotName.length() - 16); if (suffix.startsWith(Snapshot.TIMESTAMP_PREFIX)) { return Snapshot.DATE_FORMAT_SNAPSHOT.parse(suffix.substring(2)).getTime(); } else { return 0; } } catch (Throwable e) { return 0; } }    }
@Test public void testGetSnapshotTimestamp() throws ParseException { String timestampStr = "20180309110025"; long timestampMS = 1520560825000L; long snapshotTimestamp = SnapshotUtil.getSnapshotTimestamp("table1_S" + timestampStr); Date date = Snapshot.DATE_FORMAT_SNAPSHOT.parse(timestampStr); Assert.assertEquals(date.getTime(), snapshotTimestamp); Assert.assertEquals(timestampMS, snapshotTimestamp); }