public class GetDayOfWeek{
public static void main(String args[]){
final String dayNames[] = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五","星期六" };
Calendar calendar = Calendar.getInstance();
Date date = new Date();
//calendar.setTime(date);
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK)-1;
//if(dayOfWeek <0)dayOfWeek=0;
System.out.println(dayNames[dayOfWeek]);
}
默认情况下。
calendar.get(Calendar.DAY_OF_WEEK)活动的枚举值中Sunday为1,Monday为2.以此类推