Here you can find the source of getScheduledDate(int dayOfWeek, int hourOfDay, int minute, int second)
Parameter | Description |
---|---|
dayOfWeek | a parameter |
hourOfDay | a parameter |
minute | a parameter |
second | a parameter |
public static final Calendar getScheduledDate(int dayOfWeek, int hourOfDay, int minute, int second)
//package com.java2s; /*//ww w .j ava 2 s . com * Copyright (C) 2012 the diamond:dogs|group * * 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; public class Main { /** * Converts input values to a {@link Calendar} * * @param dayOfWeek * @param hourOfDay * @param minute * @param second * @return a {@link Calendar}r with the provided date */ public static final Calendar getScheduledDate(int dayOfWeek, int hourOfDay, int minute, int second) { Calendar c = Calendar.getInstance(); int weekDay = c.get(Calendar.DAY_OF_WEEK); int days = dayOfWeek - weekDay; if (days < 0) { days += 7; } c.add(Calendar.DAY_OF_YEAR, days); c.set(Calendar.HOUR_OF_DAY, hourOfDay); c.set(Calendar.MINUTE, minute); c.set(Calendar.SECOND, second); return c; } }