How do we calculate previous Sunday or previous to previous Sunday or in general lets say how to find out sunday prior to n weeks? The catch is if today is Sunday then it should return today as Sunday and not last week.
Looking for Joda-Time or Java 8 time solution.
Edit: I tried
DateTime sunday = now
.minusWeeks(1)
.withDayOfWeek(DateTimeConstants.SUNDAY)
.withTimeAtStartOfDay();
DateTime previousWeekSunday = now
.minusWeeks(2)
.withDayOfWeek(DateTimeConstants.SATURDAY)
.withTime(23, 59, 59, 999);
but if current is Sunday then this logic fails as it does not give today's date.