Here you can find the source of nextDayOfWeek(Date fromDate, int dow)
public static Calendar nextDayOfWeek(Date fromDate, int dow)
//package com.java2s; //License from project: Open Source License import java.util.Calendar; import java.util.Date; public class Main { public static Calendar nextDayOfWeek(Date fromDate, int dow) { Calendar instance = Calendar.getInstance(); if (fromDate != null) { instance.setTime(fromDate);/*from www .j av a2s . c o m*/ } if (dow > 0 && dow < 8) { int diff = dow - instance.get(Calendar.DAY_OF_WEEK); if (!(diff >= 0)) { diff += 7; } instance.add(Calendar.DAY_OF_MONTH, diff); } return instance; } }