Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.GregorianCalendar; public class Main { public static byte[] calendarToBytes(GregorianCalendar cal) { return new byte[] { (byte) (cal.get(GregorianCalendar.YEAR) - 2000), (byte) cal.get(GregorianCalendar.MONTH), (byte) cal.get(GregorianCalendar.DAY_OF_MONTH), (byte) cal.get(GregorianCalendar.HOUR_OF_DAY), (byte) cal.get(GregorianCalendar.MINUTE), (byte) cal.get(GregorianCalendar.SECOND) }; } }