Java Utililty Methods Weekend

List of utility methods to do Weekend

Description

The list of methods to do Weekend are organized into topic(s).

Method

booleanIsWeekEnd(GregorianCalendar aInCal)
Is Week End
String lDayName = aInCal.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, Locale.getDefault());
if (Objects.equals(lDayName, new String("Sun")) || (Objects.equals(lDayName, new String("Sat")))) {
    return true;
return false;
booleanisWeekend(String date)
is Weekend
Calendar cal = Calendar.getInstance();
Date d = strToDtSimpleFormat(date);
cal.setTime(d);
int day = cal.get(Calendar.DAY_OF_WEEK);
if (day == Calendar.SUNDAY || day == Calendar.SATURDAY) {
    return true;
return false;
...
booleanisWeekend(String date)
is Weekend
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
Date time = null;
try {
    time = df.parse(date);
} catch (ParseException e) {
    e.printStackTrace();
Calendar cal = Calendar.getInstance();
...
booleanisWeekend(String date)
is Weekend
if (getCurWeekDayByStr(date) == 1 || getCurWeekDayByStr(date) == 7) {
    return true;
return false;
booleanisWeekend(String dateStr)
is Weekend
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();
...
booleanisWeekend(String datestr)
is Weekend
if (datestr == null || "".equals(datestr.trim())) {
    return false;
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd");
try {
    Date date = myFormatter.parse(datestr);
    Calendar calendar = new GregorianCalendar();
    calendar.setTime(date);
...
booleanisWeekends(String date, String pattern)
is Weekends
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;
return false;