I have some legacy code like this
final Calendar cal = new GregorianCalendar();
cal.setTime(today);
// changed on May-03-2004
//cal.set(Calendar.DAY_OF_WEEK, cal.getFirstDayOfWeek());
if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
cal.add(Calendar.DAY_OF_YEAR, -6);
} else {
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
}
//System.out.println("Begin of cycle: " + cal.getTime());
And I would like to convert it to use java.time TemporalAdjuster class to hopefully make it more readable.
But I am not really sure how to interpret https://stackoverflow.com/a/1319484/242042 to make the behaviour match.