Here you can find the source of setDate(Date dateToSet, int hours, int minutes, int seconds, int milisec, TimeZone zone, Locale locale)
Parameter | Description |
---|---|
dateToSet | the date to set |
hours | the hours |
minutes | the minutes |
seconds | the seconds |
milisec | the milisec |
zone | the zone |
locale | the a locale |
public static Date setDate(Date dateToSet, int hours, int minutes, int seconds, int milisec, TimeZone zone, Locale locale)
//package com.java2s; /**//from w w w. j av a 2 s . co m * Copyright (C) 2007 Asterios Raptis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Calendar; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { /** * Returns a new {@link Date} object from the given Date object and sets the given parameters. * * @param dateToSet * the date to set * @param hours * the hours * @param minutes * the minutes * @param seconds * the seconds * @param milisec * the milisec * @param zone * the zone * @param locale * the a locale * @return the date */ public static Date setDate(Date dateToSet, int hours, int minutes, int seconds, int milisec, TimeZone zone, Locale locale) { Calendar cal = Calendar.getInstance(zone, locale); cal.setTime(dateToSet); cal.set(Calendar.HOUR_OF_DAY, hours); cal.set(Calendar.MINUTE, minutes); cal.set(Calendar.SECOND, seconds); cal.set(Calendar.MILLISECOND, milisec); return cal.getTime(); } }