Java Weekend isWeekend(String date)

Here you can find the source of isWeekend(String date)

Description

is Weekend

License

Apache License

Declaration

public static boolean isWeekend(String date) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

public class Main {
    public static boolean isWeekend(String date) {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date time = null;/*from  w  ww .  j a  v a 2  s  .  c om*/
        try {
            time = df.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        Calendar cal = Calendar.getInstance();
        cal.setTime(time);
        int day = cal.get(Calendar.DAY_OF_WEEK);
        return day == Calendar.SATURDAY || day == Calendar.SUNDAY;
    }
}

Related

  1. isWeekend(Date date)
  2. isWeekend(Date date)
  3. isWeekEnd(Date datum)
  4. IsWeekEnd(GregorianCalendar aInCal)
  5. isWeekend(String date)
  6. isWeekend(String date)
  7. isWeekend(String dateStr)
  8. isWeekend(String datestr)
  9. isWeekends(String date, String pattern)