RawDateSerialiser implements ToBytesSerialiser<Date> { @Override public byte[] serialise(final Date date) throws SerialisationException { final byte[] out = new byte[8]; final long value = date.getTime(); out[0] = (byte) ((value >> 56) & 255); out[1] = (byte) ((value >> 48) & 255); out[2] = (byte) ((value >> 40) & 255); out[3] = (byte) ((value >> 32) & 255); out[4] = (byte) ((value >> 24) & 255); out[5] = (byte) ((value >> 16) & 255); out[6] = (byte) ((value >> 8) & 255); out[7] = (byte) (value & 255); return out; }  @Override boolean canHandle(final Class clazz); @Override byte[] serialise(final Date date); @Override Date deserialise(final byte[] allBytes, final int offset, final int length); @Override Date deserialise(final byte[] bytes); @Override Date deserialiseEmpty(); @Override boolean preservesObjectOrdering(); @Override boolean isConsistent(); @Override boolean equals(final Object obj); @Override int hashCode();  }
@Test public void checkOrderPreserved() throws SerialisationException { Date now = new Date(1L); Date aDayLater = new Date(now.getTime() + 24 * 60 * 60 * 1000L); assertTrue(compare(serialiser.serialise(now), serialiser.serialise(aDayLater)) < 0); }