java判断简单判断工作日还是周末日还是周末


//工作日还是周末
    private boolean checkTimeIsWork() {
        boolean flag = false;
        try {
            DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            String date = sdf.format(new Date());
            Date testdate = sdf.parse(date);
            Calendar cal = Calendar.getInstance();
            cal.setTime(testdate);
            int x = cal.get(Calendar.DAY_OF_WEEK);
            switch (x) {
                case Calendar.MONDAY:
                case Calendar.TUESDAY:
                case Calendar.WEDNESDAY:
                case Calendar.THURSDAY:
                case Calendar.FRIDAY:
                    flag = false;
                    break;
                case Calendar.SATURDAY:
                case Calendar.SUNDAY:
                    flag = true;
                    break;
            }

        } catch (ParseException e) {
            e.printStackTrace();
        }
        return flag;
    }

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM