Here you can find the source of dateToBytes(Date d)
public static byte[] dateToBytes(Date d)
//package com.java2s; //License from project: Apache License import java.sql.Date; import java.util.Calendar; public class Main { public static byte[] dateToBytes(Date d) { Calendar cal = Calendar.getInstance(); cal.setTime(d);/*w w w . ja v a2 s . com*/ byte[] b = new byte[5]; 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); return b; } }