1
I am struggling with simple implementation. I need to receive the amount of days, excluding Saturdays and Sundays, from a certain date range. I tried using Calendar because I can set the day(date), month and year and use the calendar.get(Calendar.DAY_OF_WEEK)
that return me the day of the whole week.
for (int i = firstYear; i <= currentYear; i++) {
for (int j = firstMonth; j <= currentMonth; j++) {
for (int d = firstDay; d <= currentDay; d++) {
calendar.clear();
calendar.set(i, j-1, d); // LEMRAR QUE O MÊS COMEÇA COM 0 E NÃO COM 1
if((calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY && calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY)){
count++;
}
}
}
}
The closest I got was the code above, but when, for example, the initial month is shorter but the day is not, it does not do what it should do.
I did not understand the phrase: "the initial month is shorter but the day is not". I could explain better?
– Math