I have this method that is supposed to display the day of week given the preferred month, day, and year. When I test this method I get the wrong day and if I try to enter a higher number for the day such as 17 I get an arrayIndexOutofBoundsException: 7. I'm using the gregorianCalendar. Am I not correctly using DAY_OF_WEEK?
use getFirstDayOfWeek() and see what is the first day of the week. If this is not the first day according to your week then you can set it. And regarding the Exception you are maintaining an array so the indexes will be from 0 to 6, so use wkDay[weekday-1]. Constant field values for days
Actually, you should subtract Calendar.SUNDAY, as that's the offset. Calendar.SUNDAY just happens to be 1, but if you use this same technique for months (with Calendar.JANUARY being 0, go figure...) you won't end up in any problems.