Calendar.setFirstDayOfWeek( int value) Update the first day of the week of a Calendar.
value : Integer ( required ) value from 1 to 7 to get update the first day of week
package my_proj;
import java.util.Calendar;
public class my_first {
public static void main(String[] args) {
Calendar my_cal = Calendar.getInstance();// created calendar
System.out.println(my_cal.getWeeksInWeekYear()); // 52
my_cal.setFirstDayOfWeek(1);
System.out.println(my_cal.getWeeksInWeekYear()); // 52
}
}
We used getFirstDayOfWeek() to get the value of first day of week.
If we update the input to setFirstDayOfWeek() to 5 or beyond then the output of getWeeksInWeekYear() will change.
package my_proj;
import java.util.Calendar;
public class my_first {
public static void main(String[] args) {
Calendar my_cal = Calendar.getInstance();// created calendar
System.out.println(my_cal.getWeeksInWeekYear()); // 52
my_cal.setFirstDayOfWeek(5);
System.out.println(my_cal.getWeeksInWeekYear()); // 53
}
}