Java Weekend isWeekends(String date, String pattern)

Here you can find the source of isWeekends(String date, String pattern)

Description

is Weekends

License

Apache License

Declaration

public static boolean isWeekends(String date, String pattern) throws Exception 

Method Source Code


//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);
    }
}

Related

  1. isWeekend(String date)
  2. isWeekend(String date)
  3. isWeekend(String date)
  4. isWeekend(String dateStr)
  5. isWeekend(String datestr)