展开全部
方法1:/**
* 判断当前日期是星期几e68a84e8a2ad3231313335323631343130323136353331333335303439
*
* @param pTime 修要判断的时间
* @return dayForWeek 判断结果
* @Exception 发生异常
*/
public static int dayForWeek(String pTime) throws Exception {
format = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
c.setTime(format.parse(pTime));
int dayForWeek = 0;
if(c.get(Calendar.DAY_OF_WEEK) == 1){
dayForWeek = 7;
}else{
dayForWeek = c.get(Calendar.DAY_OF_WEEK) - 1;
}
return dayForWeek;
}
方法2:public static int dayForWeek(String pTime) throws Throwable {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
Date tmpDate = format.parse(pTime);
Calendar cal = new GregorianCalendar();
cal.set(tmpDate.getYear(), tmpDate.getMonth(), tmpDate.getDay());
return cal.get(Calendar.DAY_OF_WEEK);
}