Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static int getDayForWeekInMonth(int date, Calendar calendar) { if (date < 1 || date > 31) { return 1; } calendar.set(Calendar.DAY_OF_MONTH, date); return calendar.get(Calendar.DAY_OF_WEEK) - 1; } }