Date (@NotNull String versionId) { try { Matcher tsMatcher = ourTsPattern.matcher(versionId); if (tsMatcher.find()) { long fromTsPattern = Long.parseLong(tsMatcher.group(1)); return new Date(fromTsPattern); } else { return new Date(versionId); } } catch (IllegalArgumentException e) { return null; } }