Java Day of Week getScheduledDate(int dayOfWeek, int hourOfDay, int minute, int second)

Here you can find the source of getScheduledDate(int dayOfWeek, int hourOfDay, int minute, int second)

Description

Converts input values to a Calendar

License

Apache License

Parameter

Parameter Description
dayOfWeek a parameter
hourOfDay a parameter
minute a parameter
second a parameter

Return

a r with the provided date

Declaration

public static final Calendar getScheduledDate(int dayOfWeek, int hourOfDay, int minute, int second) 

Method Source Code

//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;
    }
}

Related

  1. getNextClosestDateTime(DayOfWeek[] daysOfWeek, int hour, int min)
  2. getNextClosestDateTime(DayOfWeek[] daysOfWeek, int hour, int min)
  3. getNextDay(long date, int startOfWeek)
  4. getNextWeekDay(Date startDate, int day)
  5. getSatDayOfWeek(Date date)
  6. getSeqWeek(String date)
  7. getSeqWeekByMonth(Date currDate)
  8. getStartDate(int year, int week)
  9. getStartDates(Date baseDate, int weekNum)