Java Week Day nextWeekday(int weekday, int hour, int minute, int second)

Here you can find the source of nextWeekday(int weekday, int hour, int minute, int second)

Description

next Weekday

License

Artistic License

Declaration

public static Date nextWeekday(int weekday, int hour, int minute, int second) 

Method Source Code


//package com.java2s;
//License from project: Artistic License 

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;

public class Main {
    public static Date nextWeekday(int weekday, int hour, int minute, int second) {
        Calendar now = now();// w w  w .  j av  a2 s.c o m

        int day = now.get(Calendar.DAY_OF_MONTH) + (7 - now.get(Calendar.DAY_OF_WEEK)) + weekday;
        return year(now.get(Calendar.MONTH), day, hour, minute, second);
    }

    public static Calendar now() {
        Calendar now = new GregorianCalendar();
        now.setTimeInMillis(new Date().getTime());
        now.setTimeZone(TimeZone.getDefault());

        return now;
    }

    public static Date year(int month, int day, int hour, int minute, int second) {
        Calendar now = now();
        return new GregorianCalendar(now.get(Calendar.YEAR), month, day, hour, minute, second).getTime();
    }
}

Related

  1. isWeekendDay(String strDay, DateFormat dateFormatter)
  2. isWeekendToday()
  3. lastDayOfWeek(int year, int month)
  4. nextDayAndHour(int dayOfTheWeek, int hour)
  5. nextTwoWeeksFromToday()
  6. parseToEntireWeekCaption(String startDay, String pattern)
  7. plusDay(Date date, int plusWeek)
  8. toDayOfWeekInMonth(Calendar c, int dayOfWeek, int weekInMonth)
  9. weekDay(int week)