Here you can find the source of isWeekend(String datestr)
public static boolean isWeekend(String datestr)
//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.GregorianCalendar; public class Main { public static boolean isWeekend(String datestr) { if (datestr == null || "".equals(datestr.trim())) { return false; }/*from w w w . ja va 2 s. co m*/ SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); try { Date date = myFormatter.parse(datestr); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { return true; } } catch (ParseException e) { return false; } return false; } }