简体   繁体   中英

Android Calendar : Changing the start day of week to Saturday

I have code to get the start date of week with current day as Sunday. But I want to start my week from Saturday-Friday. How can I achieve this through android?

This should return date of last saturday and set it as a start of the date.

Calendar cal = Calendar.getInstance();
int i = cal.get(Calendar.DAY_OF_WEEK) - cal.getFirstDayOfWeek();
cal.add(Calendar.DATE, -i - 7);
cal.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
cal.setFirstDayOfWeek(Calendar.Saturday);
Calendar cal = Calendar.getInstance();
cal.setFirstDayOfWeek(Calendar.Saturday);

i think its help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM