Here you can find the source of createDateTime(Date date, Date time)
public static Date createDateTime(Date date, Date time)
//package com.java2s; /******************************************************************************* * Copyright (c) 2010 BSI Business Systems Integration AG. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:/*from w w w . j a v a 2 s.c om*/ * BSI Business Systems Integration AG - initial API and implementation ******************************************************************************/ import java.util.Calendar; import java.util.Date; public class Main { /** * combine a date (yy/mm/dd) and a time (hh:mm:ss) into a combined timestamp-date containing both date and time. */ public static Date createDateTime(Date date, Date time) { Calendar cal1 = Calendar.getInstance(); cal1.setTime(date); Calendar cal2 = Calendar.getInstance(); cal2.setTime(time); cal1.set(Calendar.HOUR_OF_DAY, cal2.get(Calendar.HOUR_OF_DAY)); cal1.set(Calendar.MINUTE, cal2.get(Calendar.MINUTE)); cal1.set(Calendar.SECOND, cal2.get(Calendar.SECOND)); cal1.set(Calendar.MILLISECOND, cal2.get(Calendar.MILLISECOND)); return cal1.getTime(); } }