Here you can find the source of isWeekend(String dateStr)
public static boolean isWeekend(String dateStr)
//package com.java2s; /**//from w w w .j a va 2 s . c o m * Copyright (c) 2014 Xiufeng Liu ( xiufeng.liu@uwaterloo.ca ) * <p/> * This file is free software: you may copy, redistribute and/or modify it * under the terms of the GNU General Public License version 2 * as published by the Free Software Foundation. * <p/> * This file is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * <p/> * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses. */ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; public class Main { public static boolean isWeekend(String dateStr) { Calendar cal = Calendar.getInstance(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); try { cal.setTime(sdf.parse(dateStr)); int n = cal.get(Calendar.DAY_OF_WEEK); return n == Calendar.SATURDAY || n == Calendar.SUNDAY; } catch (ParseException e) { e.printStackTrace(); } return false; } }