需求如题
public static String isWeekend(String bDate) throws ParseException {
DateFormat format1 = new SimpleDateFormat("yyyy/MM/dd");
Date bdate = format1.parse(bDate);
Calendar cal = Calendar.getInstance();
cal.setTime(bdate);
if(cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY){
return "OK";
} else{
return "NO";
}
}
转自:https://blog.youkuaiyun.com/tingwufeixiang/article/details/70755713
该博客分享了一个Java方法,用于检查输入日期是否为周六或周日。通过使用`SimpleDateFormat`解析日期,然后利用`Calendar`类获取星期几,如果为周六或周日,则返回OK,否则返回NO。

被折叠的 条评论
为什么被折叠?



