Javaは時間に応じてある曜日を取得します

541 ワード

public static String getWeekOfDate(Date date) {
    /**
     *
     *     :          
     *
     * @auther: lkj
     * @date: 2018/4/3   1:46
     * @param: [date]
     * @return: java.lang.String
     *
     */
    String[] weekDays = { "   ", "   ", "   ", "   ", "   ", "   ", "   " };
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    int w = cal.get(Calendar.DAY_OF_WEEK) - 1;
    if (w < 0)
        w = 0;
    return weekDays[w];
}