Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I want to calculate Saturday's and Sunday's in a date range

I want to calculate Saturday's and Sunday's in a date range? How can i ?

like image 622
Zeeshan Avatar asked Nov 25 '22 18:11

Zeeshan


1 Answers

iterate in days and so :

Calendar date ;//initiate with your date
int day = date.get(Calendar.DAY_OF_WEEK); // 1=Sunday , 2=Monday , ...

check the day:

if(day == 1 || day == 7)
{
    //add to your list this **date** (for example List<Calender>
}

and so on.

like image 170
Sajad Bahmani Avatar answered Dec 10 '22 21:12

Sajad Bahmani