josh-cain
josh-cain

Reputation: 5226

GregorianCalendar DayofWeek

I know this has to be out there somewhere, but how does the GregorianCalendar class determine which day is the first day of the week? Does it do this by Locale, or does it remain static?

What I'm ultimately trying to do is test to determine whether it is the weekend in the United States. Any pointers?

Upvotes: 1

Views: 427

Answers (1)

Robby Pond
Robby Pond

Reputation: 73484

GregorianCalendar determines it by Locale.

You could do something like.

GregorianCalendar cal = new GregorianCalendar(someTimezone, Locale.US);
int day = cal.get(Calendar.DAY_OF_WEEK);
if (day == Calendar.SATURDAY || day == Calendar.SUNDAY) {
// do something interesting
}

Upvotes: 1

Related Questions