原创作者: zdz8207
阅读:3256次
评论:2条
更新时间:2011-05-26
public static boolean isBonusTime() { Date date = new Date(); String week = getWeekOfDate(date); if ("星期日".equals(week) || "星期二".equals(week) || "星期四".equals(week)) { Calendar ca = Calendar.getInstance(); //int hour = ca.get(Calendar.HOUR);//12小时制 int hour = ca.get(Calendar.HOUR_OF_DAY);//24小时制 if (hour >= 21) { return true; } } return false; } /** * 获取当前日期是星期几<br> * @param date * @return 当前日期是星期几 */ public static String getWeekOfDate(Date date) { String[] weekDays = { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" }; Calendar cal = Calendar.getInstance(); cal.setTime(date); int week = cal.get(Calendar.DAY_OF_WEEK) - 1; if (week < 0) { week = 0; } return weekDays[week]; }
2 楼 zdz8207 2011-03-23 17:59
就是判断是否大于21点啊
1 楼 r8HZGEmq 2011-03-21 09:15