Here you can find the source of getDayOfWeek(int year, int month, int day)
public static int[] getDayOfWeek(int year, int month, int day)
//package com.java2s; import java.util.Calendar; public class Main { public static int[] getDayOfWeek(int year, int month, int day) { int[] rtn = new int[6]; int week = 0; long longDate = 0; java.util.Date date = null; Calendar calendar1 = Calendar.getInstance(); Calendar calendar2 = Calendar.getInstance(); Calendar calendar = Calendar.getInstance(); calendar.set(year, month - 1, day); calendar.setFirstDayOfWeek(Calendar.SUNDAY); week = calendar.get(Calendar.DAY_OF_WEEK); longDate = (calendar.getTime()).getTime() - (60 * 1000 * 60 * 24 * (week - 1)); date = new java.util.Date(longDate); calendar1.setTime(date);//w ww. jav a2 s. com rtn[0] = calendar1.get(Calendar.YEAR); rtn[1] = calendar1.get(Calendar.MONTH) + 1; rtn[2] = calendar1.get(Calendar.DATE); longDate = (calendar.getTime()).getTime() + (60 * 1000 * 60 * 24 * (7 - week)); date = new java.util.Date(longDate); calendar2.setTime(date); rtn[3] = calendar2.get(Calendar.YEAR); rtn[4] = calendar2.get(Calendar.MONTH) + 1; rtn[5] = calendar2.get(Calendar.DATE); return rtn; } }