DateParser { public static Date parse(String v) { try { SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT); sdf.setTimeZone(UTC); sdf.setLenient(false); return sdf.parse(v); } catch (Exception e) { LOG.warn("Unable to parse '{}'", v); } return null; } private  DateParser(); static Date parse(String v); static String print(Date v);  }
@Test public void testInvalid() { String invalidDateString = "aaa"; Date date = DateParser.parse(invalidDateString); assertNull(date); }