Lendl Leyba
Lendl Leyba

Reputation: 2287

Calendar getFirstDayOfWeek to Sunday

Calendar.getFirstDayOfWeek() returns the first day of the week, but it's a Monday. How can I make Sunday the first day? I tried to Calendar.Day_of_week to sunday first before getfirstday, but it went terribly wrong because I just found out that these are constants.

So again, problem is that how can I set first day to sunday so that i can get the first day of the week as a sunday? TIA

Upvotes: 2

Views: 2637

Answers (1)

Divjot Singh
Divjot Singh

Reputation: 114

You get Sunday as the default response if you are in US locale. But still if you want to set it manually to a particular day you can set it by using setFirstDayOfWeek() of Calendar. You can pass SUNDAY to it.

For Example

Calendar myCalendar = Calendar.getInstance();

myCalendar.setTime(new Date());  

myCalendar.setFirstDayOfWeek(Calendar.MONDAY); 

Upvotes: 4

Related Questions