Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static int getWeek(int year, int month) { Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.YEAR, year); calendar.set(Calendar.MONTH, month - 1); calendar.set(Calendar.DAY_OF_MONTH, 1); return calendar.get(Calendar.DAY_OF_WEEK) - 1; } }