Example usage for java.util Calendar SUNDAY

List of usage examples for java.util Calendar SUNDAY

Introduction

In this page you can find the example usage for java.util Calendar SUNDAY.

Prototype

int SUNDAY

To view the source code for java.util Calendar SUNDAY.

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Sunday.

Usage

From source file:org.unitime.timetable.action.PersonalizedExamReportAction.java

public int getDaysCode(Set meetings) {
    int daysCode = 0;
    for (Iterator i = meetings.iterator(); i.hasNext();) {
        Meeting meeting = (Meeting) i.next();
        Calendar date = Calendar.getInstance(Locale.US);
        date.setTime(meeting.getMeetingDate());
        switch (date.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.MONDAY:
            daysCode |= Constants.DAY_CODES[Constants.DAY_MON];
            break;
        case Calendar.TUESDAY:
            daysCode |= Constants.DAY_CODES[Constants.DAY_TUE];
            break;
        case Calendar.WEDNESDAY:
            daysCode |= Constants.DAY_CODES[Constants.DAY_WED];
            break;
        case Calendar.THURSDAY:
            daysCode |= Constants.DAY_CODES[Constants.DAY_THU];
            break;
        case Calendar.FRIDAY:
            daysCode |= Constants.DAY_CODES[Constants.DAY_FRI];
            break;
        case Calendar.SATURDAY:
            daysCode |= Constants.DAY_CODES[Constants.DAY_SAT];
            break;
        case Calendar.SUNDAY:
            daysCode |= Constants.DAY_CODES[Constants.DAY_SUN];
            break;
        }//from ww w . ja  va2s  .  c o m
    }
    return daysCode;
}

From source file:com.panet.imeta.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions.java

public static Object dateAdd(Context actualContext, Scriptable actualObject, Object[] ArgList,
        Function FunctionContext) {
    if (ArgList.length == 3) {
        try {/* w w w .  j  av a 2 s  .  co  m*/
            if (isNull(ArgList, new int[] { 0, 1, 2 }))
                return null;
            else if (isUndefined(ArgList, new int[] { 0, 1, 2 }))
                return Context.getUndefinedValue();
            java.util.Date dIn = (java.util.Date) Context.jsToJava(ArgList[0], java.util.Date.class);
            String strType = Context.toString(ArgList[1]);
            int iValue = (int) Context.toNumber(ArgList[2]);
            Calendar cal = Calendar.getInstance();
            cal.setTime(dIn);
            if (strType.toLowerCase().equals("y"))
                cal.add(Calendar.YEAR, iValue);
            else if (strType.toLowerCase().equals("m"))
                cal.add(Calendar.MONTH, iValue);
            else if (strType.toLowerCase().equals("d"))
                cal.add(Calendar.DATE, iValue);
            else if (strType.toLowerCase().equals("w"))
                cal.add(Calendar.WEEK_OF_YEAR, iValue);
            else if (strType.toLowerCase().equals("wd")) {
                int iOffset = 0;
                while (iOffset < iValue) {
                    int day = cal.get(Calendar.DAY_OF_WEEK);
                    cal.add(Calendar.DATE, 1);
                    if ((day != Calendar.SATURDAY) && (day != Calendar.SUNDAY))
                        iOffset++;
                }
            } else if (strType.toLowerCase().equals("hh"))
                cal.add(Calendar.HOUR, iValue);
            else if (strType.toLowerCase().equals("mi"))
                cal.add(Calendar.MINUTE, iValue);
            else if (strType.toLowerCase().equals("ss"))
                cal.add(Calendar.SECOND, iValue);
            return cal.getTime();
        } catch (Exception e) {
            throw Context.reportRuntimeError(e.toString());
        }
    } else {
        throw Context.reportRuntimeError("The function call dateAdd requires 3 arguments.");
    }
}

From source file:org.apache.click.extras.control.DateField.java

/**
 * Return the names of months and weekdays as a script.
 *///from w ww  .  j  a  v  a 2s  . c  o m
protected void addCalenderTranslations(List<Element> headElements) {
    JsScript script = new JsScript();
    script.setId("datefield-js-setup-global");
    if (!headElements.contains(script)) {
        DateFormatSymbols dfs = new DateFormatSymbols(getLocale());

        HtmlStringBuffer buffer = new HtmlStringBuffer(150);
        buffer.append("Date.months=new Array(");
        generateJavaScriptArray(buffer, dfs.getMonths(), 0, 12);
        buffer.append(");\n");

        buffer.append("Date.monthAbbreviations=new Array(");
        generateJavaScriptArray(buffer, dfs.getShortMonths(), 0, 12);
        buffer.append(");\n");

        buffer.append("Date.dayNames=new Array(");
        generateJavaScriptArray(buffer, dfs.getWeekdays(), Calendar.SUNDAY, Calendar.SATURDAY + 1);
        buffer.append(");\n");

        buffer.append("Date.dayAbbreviations=new Array(");
        generateJavaScriptArray(buffer, dfs.getShortWeekdays(), Calendar.SUNDAY, Calendar.SATURDAY + 1);
        buffer.append(");\n");

        String[] weekdays = null;
        if (getMessages().containsKey("calendar-weekdays-heading")) {
            String headings = getMessage("calendar-weekdays-heading");
            weekdays = StringUtils.splitPreserveAllTokens("," + headings, ',');
        } else {
            weekdays = dfs.getShortWeekdays();
        }
        String[] days = new String[7];
        int firstDayOfWeek = getFirstDayOfWeek() - 1;
        for (int i = 0; i < 7; i++) {
            days[i] = weekdays[(i + firstDayOfWeek) % 7 + 1];
        }
        buffer.append("Date.weekdays=new Array(");
        generateJavaScriptArray(buffer, days, 0, 7);
        buffer.append(");\n");

        buffer.append("Date.first_day_of_week=").append(firstDayOfWeek).append(";\n");
        if (getMessages().containsKey("calendar-ok")) {
            buffer.append("_translations[\"OK\"] = \"");
            buffer.append(getMessage("calendar-ok"));
            buffer.append("\";\n");
        }
        if (getMessages().containsKey("calendar-now")) {
            buffer.append("_translations[\"Now\"] = \"");
            buffer.append(getMessage("calendar-now"));
            buffer.append("\";\n");
        }
        if (getMessages().containsKey("calendar-today")) {
            buffer.append("_translations[\"Today\"] = \"");
            buffer.append(getMessage("calendar-today"));
            buffer.append("\";\n");
        }
        if (getMessages().containsKey("calendar-clear")) {
            buffer.append("_translations[\"Clear\"] = \"");
            buffer.append(getMessage("calendar-clear"));
            buffer.append("\";\n");
        }

        script.setContent(buffer.toString());
        headElements.add(script);
    }
}

From source file:com.frey.repo.DateUtil.java

/**
 * ??/*  w w w .j  a  v  a  2 s.c o m*/
 */
public static Date getSundayOfWeek(Date date) {
    Calendar sunday = Calendar.getInstance();
    sunday.setTime(date);
    sunday.setFirstDayOfWeek(FIRST_DAY_OF_WEEK);
    sunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    return sunday.getTime();
}

From source file:com.ah.ui.actions.teacherView.TvRedirectionAction.java

private boolean hasClassToday(final TvClassSchedule period) {
    String periodWeekday = period.getWeekdaySecString();
    String currentWeekday = AhDateTimeUtil.getCurrentWeekDay(getUserTimeZone());

    if (TvClassSchedule.MONDAY_TO_FRIDAY.equals(period.getWeekdaySec())) {
        int day = AhDateTimeUtil.getDatePart(new Date(), "w", getUserTimeZone());

        if (day > Calendar.SUNDAY && day < Calendar.SATURDAY) {
            return true;
        }//w  w  w . j  a  v a  2  s.co m
    } else {
        if (periodWeekday.toLowerCase().contains(currentWeekday.toLowerCase().substring(0, 3))) {
            return true;
        }
    }

    return false;
}

From source file:org.pentaho.di.trans.steps.scriptvalues_mod.ScriptValuesAddedFunctions.java

public static Object dateAdd(Context actualContext, Scriptable actualObject, Object[] ArgList,
        Function FunctionContext) {
    if (ArgList.length == 3) {
        try {//from   w  ww .  jav  a  2s . c om
            if (isNull(ArgList, new int[] { 0, 1, 2 })) {
                return null;
            } else if (isUndefined(ArgList, new int[] { 0, 1, 2 })) {
                return Context.getUndefinedValue();
            }
            java.util.Date dIn = (java.util.Date) Context.jsToJava(ArgList[0], java.util.Date.class);
            String strType = Context.toString(ArgList[1]).toLowerCase();
            int iValue = (int) Context.toNumber(ArgList[2]);
            Calendar cal = Calendar.getInstance();
            cal.setTime(dIn);
            if (strType.equals("y")) {
                cal.add(Calendar.YEAR, iValue);
            } else if (strType.equals("m")) {
                cal.add(Calendar.MONTH, iValue);
            } else if (strType.equals("d")) {
                cal.add(Calendar.DATE, iValue);
            } else if (strType.equals("w")) {
                cal.add(Calendar.WEEK_OF_YEAR, iValue);
            } else if (strType.equals("wd")) {
                int iOffset = 0;
                while (iOffset < iValue) {
                    int day = cal.get(Calendar.DAY_OF_WEEK);
                    cal.add(Calendar.DATE, 1);
                    if ((day != Calendar.SATURDAY) && (day != Calendar.SUNDAY)) {
                        iOffset++;
                    }
                }
            } else if (strType.equals("hh")) {
                cal.add(Calendar.HOUR, iValue);
            } else if (strType.equals("mi")) {
                cal.add(Calendar.MINUTE, iValue);
            } else if (strType.equals("ss")) {
                cal.add(Calendar.SECOND, iValue);
            }
            return cal.getTime();
        } catch (Exception e) {
            throw Context.reportRuntimeError(e.toString());
        }
    } else {
        throw Context.reportRuntimeError("The function call dateAdd requires 3 arguments.");
    }
}

From source file:com.leavjenn.smoothdaterangepicker.date.SmoothDateRangePickerFragment.java

@SuppressWarnings("unused")
public void setFirstDayOfWeek(int startOfWeek, int startWeekEnd) {
    if (startOfWeek < Calendar.SUNDAY || startOfWeek > Calendar.SATURDAY) {
        throw new IllegalArgumentException("Value must be between Calendar.SUNDAY and " + "Calendar.SATURDAY");
    }/*from www  .  j  a v a2s. c  o  m*/
    mWeekStart = startOfWeek;

    if (mDayPickerView != null) {
        mDayPickerView.onChange();
    }

    if (mDayPickerViewEnd != null) {
        mDayPickerViewEnd.onChange();
    }
}

From source file:com.borax12.materialdaterangepicker.date.DatePickerDialog.java

@SuppressWarnings("unused")
public void setFirstDayOfWeek(int startOfWeek, int startWeekEnd) {
    if (startOfWeek < Calendar.SUNDAY || startOfWeek > Calendar.SATURDAY) {
        throw new IllegalArgumentException("Value must be between Calendar.SUNDAY and " + "Calendar.SATURDAY");
    }/*from  w w w .  ja  va  2s  .c om*/
    mWeekStart = startOfWeek;
    mWeekStartEnd = startWeekEnd;

    if (mDayPickerView != null) {
        mDayPickerView.onChange();
    }

    if (mDayPickerViewEnd != null) {
        mDayPickerViewEnd.onChange();
    }
}

From source file:joshuatee.wx.ModelInterfaceActivity.java

private String ConvertTimeRuntoTimeString(String run_str, String time_str) {

    int run_int = Integer.parseInt(run_str);
    int time_int = Integer.parseInt(time_str);
    int real_time_gmt = run_int + time_int;
    TimeZone tz = TimeZone.getDefault();
    Date now = new Date(System.currentTimeMillis());
    int offsetFromUtc = tz.getOffset(now.getTime()) / 1000;
    int real_time = real_time_gmt + offsetFromUtc / 60 / 60;
    int hour_of_day = real_time % 24;
    String am_pm = "";
    if (hour_of_day > 11) {
        am_pm = "pm";
        if (hour_of_day > 12) {
            hour_of_day = hour_of_day - 12;
        }//from  w  w w . j  a v  a 2 s  . c  om
    } else {
        am_pm = "am";
    }

    int day = (int) real_time / 24;

    if (hour_of_day < 0) {
        hour_of_day = 12 + hour_of_day;
        am_pm = "pm";
        day--;
    }

    Calendar calendar = Calendar.getInstance();
    int day_of_week = calendar.get(Calendar.DAY_OF_WEEK);
    int hour_of_day_local = calendar.get(Calendar.HOUR_OF_DAY);

    if (run_int >= 0 && run_int < -offsetFromUtc / 60 / 60
            && (hour_of_day_local - offsetFromUtc / 60 / 60) >= 24) {
        day++;
    }

    String future_day = "";

    switch ((day_of_week + day) % 7) {
    case Calendar.SUNDAY:
        future_day = "Sun";
        break;
    case Calendar.MONDAY:
        future_day = "Mon";
        break;
    case Calendar.TUESDAY:
        future_day = "Tue";
        break;
    case Calendar.WEDNESDAY:
        future_day = "Wed";
        break;
    case Calendar.THURSDAY:
        future_day = "Thu";
        break;
    case Calendar.FRIDAY:
        future_day = "Fri";
        break;
    case 0:

        future_day = "Sat";
        break;
    }

    //return  future_day + "  "+hour_of_day.toString()+ am_pm;
    return future_day + "  " + Integer.toString(hour_of_day) + am_pm;

}

From source file:com.aimluck.eip.project.ProjectTaskSelectData.java

/**
 * ??????//  w w w.  j  av a2s.c  o  m
 *
 * @return TRUE:??
 */

public boolean isSunday(int days) {
    Calendar cal = (Calendar) calFrom.clone();
    cal.add(Calendar.DAY_OF_MONTH, days - 1);
    return Calendar.SUNDAY == cal.get(Calendar.DAY_OF_WEEK);
}