Here you can find the source of isWeekends(String date, String pattern)
public static boolean isWeekends(String date, String pattern) throws Exception
//package com.java2s; //License from project: Apache License import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; public class Main { public static boolean isWeekends(String date, String pattern) throws Exception { GregorianCalendar gc = new GregorianCalendar(); gc.setTime(getDate(date, pattern)); int ret = gc.get(Calendar.DAY_OF_WEEK) - 1; if (ret == 0 || ret == 6) { return true; }/*from w ww .j av a 2 s . c om*/ return false; } public static Date getDate(String date, String pattern) throws Exception { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); return simpleDateFormat.parse(date); } }