判断当前时间为星期几

 1  Calendar cal = Calendar.getInstance();
 2         int data=cal.get(Calendar.DAY_OF_WEEK);
 3         if(data==Calendar.MONDAY){
 4           System.out.println("周一");
 5         }else if (data==Calendar.TUESDAY){
 6             System.out.println("周二");
 7         }else if (data==Calendar.WEDNESDAY){
 8             System.out.println("周三");
 9         }else if (data==Calendar.THURSDAY){
10             System.out.println("周四");
11         }else if (data==Calendar.FRIDAY){
12             System.out.println("周五");
13         }else if (data==Calendar.SATURDAY){
14             System.out.println("周六");
15         }else if (data==Calendar.SUNDAY){
16             System.out.println("周天");
17         }

 

posted @ 2020-04-14 17:38  养九  阅读(1635)  评论(0编辑  收藏  举报