Here you can find the source of timeStampToBytes(Timestamp ts)
public static byte[] timeStampToBytes(Timestamp ts)
//package com.java2s; //License from project: Apache License import java.sql.Timestamp; import java.util.Calendar; public class Main { public static byte[] timeStampToBytes(Timestamp ts) { Calendar cal = Calendar.getInstance(); cal.setTime(ts);//from w w w . j ava 2 s .c o m byte[] b = new byte[12]; b[0] = (byte) 0; b[1] = (byte) (cal.get(Calendar.YEAR) & 0xff); b[2] = (byte) (cal.get(Calendar.YEAR) >>> 8); b[3] = (byte) (cal.get(Calendar.MONTH) & 0xff); b[4] = (byte) (cal.get(Calendar.DATE) & 0xff); b[5] = (byte) (cal.get(Calendar.HOUR) & 0xff); b[6] = (byte) (cal.get(Calendar.MINUTE) & 0xff); b[7] = (byte) (cal.get(Calendar.SECOND) & 0xff); b[8] = (byte) (ts.getNanos() & 0xff); b[9] = (byte) (ts.getNanos() >>> 8); b[10] = (byte) (ts.getNanos() >>> 16); b[11] = (byte) (ts.getNanos() >>> 24); return b; } }