// 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.*;

public class DayFun {
    public static Date NextWeekday(int weekday) {
        Calendar cal = Calendar.getInstance();
        while(cal.get(Calendar.DAY_OF_WEEK) != weekday)
        {
            cal.add(Calendar.DAY_OF_MONTH, 1);
        }
        return cal.getTime();
    }
    public static void main(String[] args) {
        System.out.println(NextWeekday(Calendar.THURSDAY));
        System.out.println(NextWeekday(Calendar.MONDAY));
    }
}
