相关疑难解决方法(0)

Android日历:更改星期的开始日期

我有一点问题,我正在开发一个应用程序,我需要将一周的开始日从星期一改为另一个星期四(星期六,星期六).这是可能的android,我需要计算一周的开始和知道日期的结束.(本周开始以星期四为例)

注意:我只是android开发的初学者.这是我的代码SimpleDateFormat dateformate = new SimpleDateFormat("dd/MM");

// get today and clear time of day
Calendar cal = Calendar.getInstance();

// get start of this week in milliseconds
cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
cal.add(Calendar.DAY_OF_YEAR, 7*(WeekIndex-1));
result = dateformate.format(cal.getTime());

cal.add(Calendar.DAY_OF_YEAR, 6 );

result=result+" - " + dateformate.format(cal.getTime());
Run Code Online (Sandbox Code Playgroud)

使用上面的代码我得到的结果,但星期一作为星的星.

注意:我无法在结果中添加日期,因为周指数随着其开始的变化而变化

java android calendar

8
推荐指数
1
解决办法
2万
查看次数

标签 统计

android ×1

calendar ×1

java ×1