import java.util.Calendar;
public class GetWeek {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int year = 2008;
int month = 6;
int day = 1;
int week = getTheFirstDayWeekOfMonth(year,month,day);
}
public static int getTheFirstDayWeekOfMonth(int year,int month,int day){
int week = 0 ;
Calendar cal = Calendar.getInstance();
cal.set(cal.YEAR, year);
cal.set(cal.MONTH, month-1);
cal.set(cal.DATE, day);
week = cal.get(cal.DAY_OF_WEEK)-1;
System.out.println(week);
return week;
}
}
取出特定年月日的星期
最新推荐文章于 2024-03-05 11:17:58 发布