I would make a method that gave me the number of days that have passed since that day.
public static int daysSince(int day) {
return daysSince(day, Calendar.getInstance());
}
public static int daysSince(int day, Calendar now) {
int today = now.get(Calendar.DAY_OF_WEEK);
int difference = today - day;
if(difference <= 0) difference += 7;
return difference;
}
public static void callingMethod() {
int daysPassed = daysSince(Calendar.FRIDAY);
Calendar lastFriday = Calendar.getInstance().add(Calendar.DAY_OF_WEEK, -daysPassed);
}
source
share