JAVA代码片段--获取当前是星期几



天猫内部优惠券


public void getDate(){
String[] weekDays = {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"};
    Calendar cal = Calendar.getInstance();
    Date curDate = new Date(System.currentTimeMillis());
    cal.setTime(curDate);
    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
    if (w < 0)
        w = 0;
    
    System.out.println("--------------"+weekDays[w]);
}


你可能感兴趣的:(Java)