根据当前日期得知今天星期几
public String getWeekOfDate(String sdate) {
Date dt = strToDate(sdate);
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
Calendar cal = Calendar.getInstance();
cal.setTime(dt);
int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (w < 0)
w = 0;
return weekDays[w];
}
传入的参数格式是:“2021-06-01”