Here you can find the source of fillBufFromTime(ByteBuffer buf, Calendar cal)
private static void fillBufFromTime(ByteBuffer buf, Calendar cal)
//package com.java2s; /*/*from www . ja va 2 s . co m*/ * Copyright (C) 2006 Steve Ratcliffe * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * Author: Steve Ratcliffe * Create date: 03-Dec-2006 */ import java.nio.ByteBuffer; import java.util.Calendar; public class Main { private static void fillBufFromTime(ByteBuffer buf, Calendar cal) { buf.putChar((char) cal.get(Calendar.YEAR)); buf.put((byte) (cal.get(Calendar.MONTH) + 1)); buf.put((byte) cal.get(Calendar.DAY_OF_MONTH)); buf.put((byte) cal.get(Calendar.HOUR_OF_DAY)); buf.put((byte) cal.get(Calendar.MINUTE)); buf.put((byte) cal.get(Calendar.SECOND)); } }