Here you can find the source of isWeekday(String dateStr, String format)
public static boolean isWeekday(String dateStr, String format)
//package com.java2s; //License from project: Open Source License import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.TimeZone; public class Main { static public final String FORMAT_NORMAL = "yyyy-MM-dd HH:mm:ss"; public static boolean isWeekday(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date);/*from www. j a v a2s.com*/ int w = cal.get(Calendar.DAY_OF_WEEK) - 1; return w > 0 && w < 6; } public static boolean isWeekday(String dateStr, String format) { Date date = parse(dateStr, format); return date != null && isWeekday(date); } public static boolean isWeekday(String dateStr) { return isWeekday(dateStr, FORMAT_NORMAL); } public static Date parse(String str, String format) { try { SimpleDateFormat sf = new SimpleDateFormat(format); sf.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai")); return sf.parse(str); } catch (ParseException e) { e.printStackTrace(); return null; } } }