java获取当前日期是星期几

     /**
     * 获取当前日期是星期几

     *
     * @param dt
     * @return 当前日期是星期几
     */
    public static String getWeekOfDate(Date dt) {
        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];
    }

 

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/hjy273/archive/2009/04/23/4102572.aspx

你可能感兴趣的:(java获取当前日期是星期几)