// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.util.Calendar;
import java.util.Date;

public class StartOfWeek {
    public static Date rollStartOfWeek(Date d) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(d);
        while(cal.get(Calendar.DAY_OF_WEEK) != cal.getFirstDayOfWeek()) cal.add(Calendar.DAY_OF_WEEK, -1);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }
    public static void main(String[] args) {
        Date now = new Date();
        System.out.println("now = " + now);
        Date sow = rollStartOfWeek(now);
        System.out.println("sow = " + sow);
    }
}
