我试图找回当月的当前一周
TimeZone timezone = TimeZone.getDefault();
Calendar c = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
c.set(year, month, day);
// Set the calendar to monday of the current week
c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
c.add(Calendar.DATE, num * 7);
// Print dates of the current week starting on Monday
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd", Locale.ENGLISH);
String[] days = new String[7];
for (int i = 0; i < 7; i++) {
days[i] = df.format(c.getTime());
c.add(Calendar.DAY_OF_MONTH, 1);
}
return days;
其中yr mnth和day将作为函数的参数传递...而num值将为laways-1。它在手机中返回正确的值。但在标签中我得到了前一周。两个设备的操作系统以及日期和时区相同。
如果你们有任何解决方案,请分享