Java tutorial
//package com.java2s; import java.util.Calendar; import java.util.Date; public class Main { public static int getFirstDayOfWeek(Date date) { int n = getDayOfWeek(date); Calendar c = Calendar.getInstance(); c.setTime(date); c.set(Calendar.DAY_OF_MONTH, c.get(Calendar.DAY_OF_MONTH) - n + 1); return c.get(Calendar.DAY_OF_MONTH); } public static int getDayOfWeek() { return getDayOfWeek(new Date()); } public static int getDayOfWeek(Date date) { Calendar c = Calendar.getInstance(); c.setTime(date); return c.get(Calendar.DAY_OF_WEEK); } }