TlvEncoder { public static byte[] encodeDate(Date value) { ByteBuffer tBuf = ByteBuffer.allocate(4); tBuf.putInt((int) (value.getTime() / 1000L)); return tBuf.array(); }  static ByteBuffer encode(Tlv[] tlvs); static byte[] encodeInteger(Number number); static byte[] encodeFloat(Number number); static byte[] encodeBoolean(boolean value); static byte[] encodeString(String value); static byte[] encodeDate(Date value); static byte[] encodeObjlnk(ObjectLink value);  }
@Test public void encode_date() { long timestamp = System.currentTimeMillis(); byte[] encoded = TlvEncoder.encodeDate(new Date(timestamp)); ByteBuffer bb = ByteBuffer.wrap(encoded); assertEquals((int) (timestamp / 1000), bb.getInt()); assertEquals(0, bb.remaining()); }