DateTimeCodec implements BlockCodec<Date> { @Override public Date decode(byte[] data, int bitLength) throws BlockCodecException { try { long value = ByteUtils.longValue(data, bitLength); return new Date(value); } catch (Exception ex) { throw new BlockCodecException("Date decode failure. " + ex.getMessage(), ex); } }  @Override Date zeroValue(); @Override Date decode(byte[] data, int bitLength); @Override byte[] encode(Date data, int bitLength); @Override void reset(); @Override String getValueType();  }
@Test public void testDecode() throws Exception { long time = System.currentTimeMillis(); byte[] timeBytes = ByteBuffer.allocate(8).putLong(time).array(); DateTimeCodec codec = new DateTimeCodec(); Assert.assertEquals(time, codec.decode(timeBytes, 64).getTime(), 0); }