日期:2014-05-20 浏览次数:20941 次
String date="20110127"; Calendar calendar=Calendar.getInstance(); calendar.setTime(new SimpleDateFormat("yyyyMMdd").parse(date)); int dayOfWeek=calendar.get(Calendar.DAY_OF_WEEK); int dayOfMonth=calendar.get(Calendar.DAY_OF_MONTH); System.out.println(dayOfWeek); System.out.println(dayOfMonth); int friday=5; int endMonth=calendar.getActualMaximum(Calendar.DAY_OF_MONTH); System.out.println(friday); System.out.println(endMonth); if(friday==dayOfWeek){ System.out.println("今天星期五!"); }else{ System.out.println("今天不是星期五,明天接着上班!"); } if(endMonth==dayOfMonth){ System.out.println("今天月末!"); }else{ System.out.println("今天还无到月末!"); }