首页 > 学院 > 开发设计 > 正文

Calendar的使用经历,验证时间段

2019-11-10 17:47:37
字体:
来源:转载
供稿:网友
/**     * TODO 验证时间     * @return     */    public boolean getWithdrawTime(){        Date date = new Date();        Calendar nowCalendar = Calendar.getInstance();        nowCalendar.setTime(date);        if(nowCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || nowCalendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){            return false;        }        if(nowCalendar.compareTo(getStartWithdrawTime(date)) == -1 || nowCalendar.compareTo(getEndWithdrawTime(date)) == 1){            return false;        }        return true;    }    /**     * TODO 设置开始时间     * @param date     * @return     */    public Calendar getStartWithdrawTime(Date date){        Calendar calendar = Calendar.getInstance();        calendar.setTime(date);        calendar.set(Calendar.HOUR_OF_DAY,8);        calendar.set(Calendar.MINUTE,00);        return calendar;    }    /**     * TODO 设置结束时间     * @param date     * @return     */    public Calendar getEndWithdrawTime(Date date){        Calendar calendar = Calendar.getInstance();        calendar.setTime(date);        calendar.set(Calendar.HOUR_OF_DAY,20);        calendar.set(Calendar.MINUTE,00);        return calendar;    }   欢迎提供宝贵意见!
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表