### Question:
DateAccessor implements PropertyAccessor<Date> { @Override public Date fromString(Class targetClass, String s) { try { if (s == null) { return null; } Date d = getDateByPattern(s); return d; } catch (NumberFormatException e) { log.error("Number format exception, Caused by {}.", e); throw new PropertyAccessException(e); } }  @Override Date fromBytes(Class targetClass, byte[] bytes); @Override byte[] toBytes(Object date); @Override String toString(Object object); @Override Date fromString(Class targetClass, String s); static Date getDateByPattern(String date); @Override Date getCopy(Object object); static String getFormattedObect(String date); Date getInstance(Class<?> clazz);  }### Answer:
@Test public void testDateFromString() throws PropertyAccessException { String dateInMMddYYHHmmss = "02/01/2012 00:00:00"; String newDateAsStr = "Wed Feb 01 07:58:02 IST 2012"; String dateInMMddYY = "02/01/2012"; String dateInMMddYYDash = "02-01-2012"; String dateInMMMddYYYY = "Feb/02/2012"; String dateInMilliSeconds = "1351667541111"; Assert.assertNotNull(accessor.fromString(Date.class, dateInMMddYYDash)); Assert.assertNotNull(accessor.fromString(Date.class, dateInMMddYYHHmmss)); Assert.assertNotNull(accessor.fromString(Date.class, newDateAsStr)); Assert.assertNotNull(accessor.fromString(Date.class, dateInMMMddYYYY)); Assert.assertNotNull(accessor.fromString(Date.class, dateInMMddYY)); Assert.assertNotNull(accessor.fromString(Date.class, dateInMilliSeconds)); }