Code example for Timestamp

public class MongoTimestampTest { 
    public void testTimestamp() { 
        Map<String, Timestamp> json = new HashMap<>();
        json.put("_", new Timestamp(258));
        Buffer buffer = BSON.encode(json);
        byte[] expected = new byte[] {
                // length 
                0x10, 0x00, 0x00, 0x00, 
                0x11, '_', 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
                // end 
        assertArrayEquals(expected, buffer.getBytes());
        // reverse 
        Map document = BSON.decode(new Buffer(expected));
        assertEquals(json, document);
Connect your IDE to all the code out there  Get Codota for Java