### Question:
TimestampValidator implements ValidationPolicy<String> { @Override public boolean validate(String value) { if (!StringUtils.isEmpty(value)) { try { parseTimestamp(value); return true; } catch (IllegalArgumentException e) { log.debug("Invalid timestamp format [{}]", value); return false; } } else { return allowNull; } } TimestampValidator(@PolicyPropertyRef(name = "allowNull") boolean allowNull);  TimestampValidator(); @Override boolean validate(String value); DateTime parseTimestamp(String value); boolean getAllowNull(); boolean isAllowNull(); void setAllowNull(boolean allowNull);  }### Answer:
@Test public void testInstance() throws Exception { TimestampValidator ts = new TimestampValidator(false); assertTrue(ts.validate("2015-01-15 11:10:20.333")); assertTrue(ts.validate("2015-01-15 11:10:20")); assertTrue(ts.validate("2015-01-15 11:10:20.333444555")); assertTrue(ts.validate("2016-02-03T07:55:29Z")); assertTrue(ts.validate("1994-11-05T08:15:30-05:00")); assertFalse(ts.validate("2015/01/15 11:10:20")); assertFalse(ts.validate("2015-01-15")); }
@Test public void testNull() throws Exception { TimestampValidator ts = new TimestampValidator(true); assertTrue(ts.validate(null)); assertTrue(ts.validate("NULL")); assertTrue(ts.validate("null")); }