I need to get the number of all days of the week (from MON to SUN) based on which day is sent as a parameter.
For instance,
I pass on May 2 and I get an array [30,1,2,3,4,5,6], which is actually this week.
Or I turn in on May 16 and I get an array [14,15,16,17,18,19,20].
I tried to use this code, but it returns after 7 days from today, which I do not want.
//get which week of month Calendar now = Calendar.getInstance(); now.set(mYear, mMonth, Integer.parseInt(extractedDay)); int weekOfMonth = now.get(Calendar.WEEK_OF_MONTH); //get all days of clicked week SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy"); Calendar calendar = Calendar.getInstance(); calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.set(mYear, mMonth, Integer.parseInt(extractedDay)); String[] days = new String[7]; for (int i = 0; i < 7; i++) { days[i] = format.format(calendar.getTime()); calendar.add(Calendar.DAY_OF_MONTH, 1); }
But that is not what I need. I need to go today day (THU) and get the dates of this week of May - Monday, April 30 to the Sun, May 6.
EDIT
I realized that I have a code that determines which week of the month. Is there any way to use this data and set the date for Monday? For example, I walk through May 16th and then discover that this is the 3rd week of May, and I set the variable firstDayOfWeek
(new variable) until May 14th.
source share