Return to Snippet

Revision: 51015
at September 12, 2011 19:21 by RobEllis


Initial Code
private Date combineDateTime(Date date, Date time)
{
	Calendar calendarA = Calendar.getInstance();
	calendarA.setTime(date);
	Calendar calendarB = Calendar.getInstance();
	calendarB.setTime(time);

	calendarA.set(Calendar.HOUR_OF_DAY, calendarB.get(Calendar.HOUR_OF_DAY));
	calendarA.set(Calendar.MINUTE, calendarB.get(Calendar.MINUTE));
	calendarA.set(Calendar.SECOND, calendarB.get(Calendar.SECOND));
	calendarA.set(Calendar.MILLISECOND, calendarB.get(Calendar.MILLISECOND));

	Date result = calendarA.getTime();
	return result;
}

Initial URL

                                

Initial Description

                                

Initial Title
Combine a date and a time into a single date-time using java.util.Date

Initial Tags
date

Initial Language
Java