【发布时间】:2018-10-05 12:00:42
【问题描述】:
实际上,我想显示一组数据,其中包含特定日期所在的一周的开始和结束日期。在我的模拟器中它工作正常。例如。如果我给 4 月 23 日,它给我一周的开始日期为 4 月 22 日,结束日期为 4 月 28 日,但如果我尝试在我的设备中构建相同的代码,它显示一周的开始日期为 4 月 27 日,结束日期为 28四月
我正在使用的代码片段:
//to get first day of week
cal1.set(Calendar.DAY_OF_WEEK, 1);
int day1 = cal1.get(Calendar.DAY_OF_MONTH);
//to get last day of week
cal1.set(Calendar.DAY_OF_WEEK, 7);
int day7 = cal1.get(Calendar.DAY_OF_MONTH);
【问题讨论】:
-
我相信我已经看到了其他关于
Calendar的 Android 实现中可能存在错误的问题,当涉及到星期几时。 (1)Getting issues on get current week days on some device (2)Android Calendar problem with day of the week
标签: android android-calendar dayofweek