Mustgo
Mustgo

Reputation: 5

Get all Weekend in given month with Jalali Calendar in Java

i´m trying to get the Date of Weekends in given month with Jalali Calendar.but i doesnt work. i used this and this solution to solve it but i get same result when i change the month

public static void main(String[] args) {
        ULocale locale = new ULocale("@calendar=persian");
        Calendar cal = Calendar.getInstance(locale);
        cal.setFirstDayOfWeek(7); //Make Saturdays first day of the week.
        cal.set(Calendar.YEAR,1398);
        cal.set(Calendar.MONTH,10);
        cal.set(Calendar.DATE,1);


        do {
            // get the day of the week for the current day
            int day = cal.get(Calendar.DAY_OF_WEEK);
            // check if it is a Saturday or Sunday
            if (day == Calendar.FRIDAY) {//Friday is Weekend in Jalali Calendar

                System.out.println(cal.get(Calendar.DAY_OF_MONTH));
            }
            // advance to the next day
            cal.add(Calendar.DAY_OF_YEAR, 1);
        }  while (cal.get(Calendar.MONTH) == 10);




    }

Any help would be appreciated

Upvotes: 0

Views: 174

Answers (0)

Related Questions