Sure.
One option is to iterate through the days of the month, for each day test whether it's a Monday or Friday, if it is, print in.
A bit more complicated, test the weekday of the first of the month, determine how many days to add to get to the first Monday or Friday in the month. Every time you have a Monday, add four days to get to Friday. On every Friday, add three days to get to Monday. When in next month, stop.
If you run into problems, please post again.
> This code:
>
> > Calendar rightNow = Calendar.getInstance();
> ce();
>int dayofmonth = rightNow.DAY_OF_MONTH;
>System.out.println(dayofmonth);
>
>
> prints 5 eventhough we have the 14 of may
>. Do I have
> to initialize it with the year or something?
No, but you have to use it properly. DAY_OF_MONTH is a constant.
You want to use a method that gets the field you want (specified with one of the constants.
int dayofmonth = rightNow.get(Calendar.DAY_OF_MONTH);
Ok so this:
Calendar rightNow = Calendar.getInstance();
// Number of days in this month:
int days = rightNow.getActualMaximum(Calendar.DAY_OF_MONTH);
// date in current month:
int date = rightNow.get(Calendar.DAY_OF_MONTH);
// day in current week:
int day = rightNow.get(Calendar.DAY_OF_WEEK);
System.out.println(days + "\n" + date + "\n" + day);
is better right? When printing "day" I get 2. Are Mondays numbered 2 and sundays numbered 1 etc?