@Override void setTo(Calendar c, int i) { int v = i-offset; int was = c.get(field); c.set(field,v); final int firstDayOfWeek = c.getFirstDayOfWeek(); if (v < firstDayOfWeek && was >= firstDayOfWeek) { // in crontab, the first DoW is always Sunday, but in Java, it can be Monday or in theory arbitrary other days. // When first DoW is 1/2 Monday, calendar points to 1/2 Monday, setting the DoW to Sunday makes // the calendar moves forward to 1/8 Sunday, instead of 1/1 Sunday. So we need to compensate that effect here. addTo(c,-7); } else if (was < firstDayOfWeek && firstDayOfWeek <= v) { // If we wrap the other way around, we need to adjust in the opposite direction of above. addTo(c, 7); } } };
@Override void setTo(Calendar c, int i) { int v = i-offset; int was = c.get(field); c.set(field,v); final int firstDayOfWeek = c.getFirstDayOfWeek(); if (v < firstDayOfWeek && was >= firstDayOfWeek) { // in crontab, the first DoW is always Sunday, but in Java, it can be Monday or in theory arbitrary other days. // When first DoW is 1/2 Monday, calendar points to 1/2 Monday, setting the DoW to Sunday makes // the calendar moves forward to 1/8 Sunday, instead of 1/1 Sunday. So we need to compensate that effect here. addTo(c,-7); } else if (was < firstDayOfWeek && firstDayOfWeek <= v) { // If we wrap the other way around, we need to adjust in the opposite direction of above. addTo(c, 7); } } };
@Override void setTo(Calendar c, int i) { int v = i-offset; c.set(field,v); if (v<c.getFirstDayOfWeek()) { // in crontab, the first DoW is always Sunday, but in Java, it can be Monday or in theory arbitrary other days. // When first DoW is 1/2 Monday, calendar points to 1/2 Monday, setting the DoW to Sunday makes // the calendar moves forward to 1/8 Sunday, instead of 1/1 Sunday. So we need to compensate that effect here. addTo(c,-7); } } };
@Override void setTo(Calendar c, int i) { int v = i - offset; c.set(field, v); if (v < c.getFirstDayOfWeek()) { // in crontab, the first DoW is always Sunday, but in Java, it can be Monday or in theory arbitrary other days. // When first DoW is 1/2 Monday, calendar points to 1/2 Monday, setting the DoW to Sunday makes // the calendar moves forward to 1/8 Sunday, instead of 1/1 Sunday. So we need to compensate that effect here. addTo(c, -7); } } };
@Override void setTo(Calendar c, int i) { int v = i-offset; c.set(field,v); if (v<c.getFirstDayOfWeek()) { // in crontab, the first DoW is always Sunday, but in Java, it can be Monday or in theory arbitrary other days. // When first DoW is 1/2 Monday, calendar points to 1/2 Monday, setting the DoW to Sunday makes // the calendar moves forward to 1/8 Sunday, instead of 1/1 Sunday. So we need to compensate that effect here. addTo(c,-7); } } };
@Override void setTo(Calendar c, int i) { int v = i-offset; c.set(field,v); if (v<c.getFirstDayOfWeek()) { // in crontab, the first DoW is always Sunday, but in Java, it can be Monday or in theory arbitrary other days. // When first DoW is 1/2 Monday, calendar points to 1/2 Monday, setting the DoW to Sunday makes // the calendar moves forward to 1/8 Sunday, instead of 1/1 Sunday. So we need to compensate that effect here. addTo(c,-7); } } };