Here you can find the source of getDateTime(Date d, int hour, int minute, int second, int millisecond)
public static Date getDateTime(Date d, int hour, int minute, int second, int millisecond)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { /**/*from w w w . j a v a2 s . c o m*/ * Returns the passed date, at the specified time */ public static Date getDateTime(int year, int mon, int day, int hr, int min, int sec, int ms) { Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, year); c.set(Calendar.MONTH, mon - 1); c.set(Calendar.DATE, day); c.set(Calendar.HOUR_OF_DAY, hr); c.set(Calendar.MINUTE, min); c.set(Calendar.SECOND, sec); c.set(Calendar.MILLISECOND, ms); return c.getTime(); } /** * Returns the passed date, at midnight */ public static Date getDateTime(int year, int mon, int day) { return getDateTime(year, mon, day, 0, 0, 0, 0); } /** * Returns the passed date, at the specified time */ public static Date getDateTime(Date d, int hour, int minute, int second, int millisecond) { Calendar c = Calendar.getInstance(); c.setTime(d); c.set(Calendar.HOUR_OF_DAY, hour); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, second); c.set(Calendar.MILLISECOND, millisecond); return c.getTime(); } }