### Question:
DateAccessor implements PropertyAccessor<Date> { @Override publicbyte[] toBytes(Object date) { try { if (date == null) { return null; } LongAccessor longAccessor = new LongAccessor(); return longAccessor.toBytes(((Date) date).getTime()); } catch (Exception e) { log.error("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 testToBytes() { Assert.assertNull(accessor.toBytes(null)); Date d1 = new Date(4); byte[] b = accessor.toBytes(d1); Date d2 = accessor.fromBytes(Date.class, b); Assert.assertEquals(d1, d2); }