if (matcher.matches()) {
try {
strValue = matcher.group(1) + matcher.group(2);
parsedValue = formatter.parseObject(strValue);
if (parsedValue instanceof java.util.Date) {
parsedValue = new NSTimestamp((Date)parsedValue);
}
} catch (Throwable t) {
String msg = "Failed to parse '" + strValue + "' as a timestamp";
if (formatter != null) {
msg += " (example: " + formatter.format(new NSTimestamp()) + ")";
}
msg += ".";
throw new IllegalArgumentException(msg, t);
}
} else {
strValue = null;
throw new IllegalArgumentException(strValue + " didn't match the " + pattern.pattern() + " pattern", new Throwable());
}
} else {
Format formatter = null;
try {
formatter = ERXRestUtils.timestampFormat(spaces, context);
parsedValue = formatter.parseObject(strValue);
}
catch (Throwable t) {
String msg = "Failed to parse '" + strValue + "' as a timestamp";
if (formatter != null) {
msg += " (example: " + formatter.format(new NSTimestamp()) + ")";
}
msg += ".";
throw new IllegalArgumentException(msg, t);
}
}