Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Calendar; public class Main { /** * the first day of month * @param year * @param month * @return week position */ public static int getDayOfWeekInMonth(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DATE, 1); return calendar.get(Calendar.DAY_OF_WEEK); } }