Here you can find the source of getDayOfWeek(Date start, int day)
Parameter | Description |
---|---|
start | current date. |
day | the day |
public static Date getDayOfWeek(Date start, int day)
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { /**/*from w w w. j av a 2 s . c om*/ * Method to get day number of week. 0 - Monday. ... 6 - Sunday. * * @param start current date. * @param day the day * @return day of week */ public static Date getDayOfWeek(Date start, int day) { if (day == 0) return start; Calendar calendar = Calendar.getInstance(); calendar.setTime(start); calendar.add(Calendar.DAY_OF_YEAR, day); return calendar.getTime(); } }