Here you can find the source of setTime(final Date date, final int hourOfDay, final int minute, final int second, final int ms)
Parameter | Description |
---|---|
date | a parameter |
hourOfDay | a parameter |
minute | a parameter |
second | a parameter |
ms | a parameter |
public static Date setTime(final Date date, final int hourOfDay, final int minute, final int second, final int ms)
//package com.java2s; /*/*from ww w . j ava 2 s .c o m*/ * Author Stephen Booysen * * Copyright (c) 2015 Stephen Booysen, Inc. All Rights Reserved. * * This software is the confidential and proprietary information of * Stephen Booysen. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Stephen Booysen * * Stephen Booysen MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { /** * Set the time of the given Date * * @param date * @param hourOfDay * @param minute * @param second * @param ms * * @return new instance of java.util.Date with the time set */ public static Date setTime(final Date date, final int hourOfDay, final int minute, final int second, final int ms) { final GregorianCalendar gc = new GregorianCalendar(); gc.setTime(date); gc.set(Calendar.HOUR_OF_DAY, hourOfDay); gc.set(Calendar.MINUTE, minute); gc.set(Calendar.SECOND, second); gc.set(Calendar.MILLISECOND, ms); return gc.getTime(); } }