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:com.borax12.materialdaterangepicker.single.date.DatePickerDialog.java

@SuppressWarnings("unused")
public void setFirstDayOfWeek(int startOfWeek) {
    if (startOfWeek < Calendar.SUNDAY || startOfWeek > Calendar.SATURDAY) {
        throw new IllegalArgumentException("Value must be between Calendar.SUNDAY and " + "Calendar.SATURDAY");
    }//  w w  w  .j av a  2 s  .  c om
    mWeekStart = startOfWeek;
    if (mDayPickerView != null) {
        mDayPickerView.onChange();
    }
}

From source file:com.appeaser.sublimepickerlibrary.datepicker.SimpleMonthView.java

private static boolean isValidDayOfWeek(int day) {
    return day >= Calendar.SUNDAY && day <= Calendar.SATURDAY;
}

From source file:org.kuali.student.r2.core.scheduling.service.impl.TestSchedulingServiceImpl.java

@Test
public void getValidDaysOfWeekByTimeSlotType() throws Exception {
    List<Integer> valid_days_act_off = schedulingService.getValidDaysOfWeekByTimeSlotType(
            SchedulingServiceConstants.TIME_SLOT_TYPE_ACTIVITY_OFFERING_STANDARD_FULLTERM_FALL, contextInfo);
    // should return days Monday through Saturday
    assertTrue(valid_days_act_off.contains(Calendar.MONDAY));
    assertTrue(valid_days_act_off.contains(Calendar.TUESDAY));
    assertTrue(valid_days_act_off.contains(Calendar.WEDNESDAY));
    assertTrue(valid_days_act_off.contains(Calendar.THURSDAY));
    assertTrue(valid_days_act_off.contains(Calendar.FRIDAY));
    assertTrue(valid_days_act_off.contains(Calendar.SATURDAY));
    assertTrue(valid_days_act_off.contains(Calendar.SUNDAY));

    List<Integer> valid_days_final = schedulingService
            .getValidDaysOfWeekByTimeSlotType(SchedulingServiceConstants.TIME_SLOT_TYPE_EXAM, contextInfo);
    // should not return any days
    assertFalse(valid_days_final.contains(Calendar.MONDAY));
    assertFalse(valid_days_final.contains(Calendar.TUESDAY));
    assertFalse(valid_days_final.contains(Calendar.WEDNESDAY));
    assertFalse(valid_days_final.contains(Calendar.THURSDAY));
    assertFalse(valid_days_final.contains(Calendar.FRIDAY));
    assertFalse(valid_days_final.contains(Calendar.SATURDAY));
    assertFalse(valid_days_final.contains(Calendar.SUNDAY));
}

From source file:org.ejbca.ui.web.admin.certprof.CertProfileBean.java

public void setExpirationRestrictionSunday(final boolean enabled) throws AuthorizationDeniedException {
    getCertificateProfile().setExpirationRestrictionWeekday(Calendar.SUNDAY, enabled);
}

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

public static int getWeekNumOfYearDay(Date curDate) {
    if (curDate == null)
        return 0;
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(curDate);//from   w  ww . j  a  va2s.  com
    int iWeekNum;
    if (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
        iWeekNum = calendar.get(Calendar.WEEK_OF_YEAR) - 1;
    } else {
        iWeekNum = calendar.get(Calendar.WEEK_OF_YEAR);
    }
    // int iWeekNum = calendar.get(Calendar.WEEK_OF_YEAR);
    return iWeekNum;
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private void init(Context context) {
    setFocusable(true);/*from  w  w  w . ja v  a 2  s.c  o m*/

    // Allow focus in touch mode so that we can do keyboard shortcuts
    // even after we've entered touch mode.
    setFocusableInTouchMode(true);
    setClickable(true);
    setOnCreateContextMenuListener(this);

    mFirstDayOfWeek = Time.MONDAY;

    mCurrentTime = new Time(DayUtils.getTimeZone(context, mTZUpdater));
    long currentTime = System.currentTimeMillis();
    mCurrentTime.set(currentTime);
    mTodayJulianDay = Time.getJulianDay(currentTime, mCurrentTime.gmtoff);

    mEventTextPaint.setTextSize(EVENT_TEXT_FONT_SIZE);
    mEventTextPaint.setTextAlign(Align.LEFT);
    mEventTextPaint.setAntiAlias(true);

    int gridLineColor = 0xff707070;
    Paint p = mSelectionPaint;
    p.setColor(gridLineColor);
    p.setStyle(Style.FILL);
    p.setAntiAlias(false);

    p = mPaint;
    p.setAntiAlias(true);

    // Long day names
    mDayStrsLong = new String[14];

    // Allocate space for 2 weeks worth of weekday names so that we can
    // easily start the week display at any week day.
    mDayStrs = new String[14];

    // Also create an array of 2-letter abbreviations.
    mDayStrs2Letter = new String[14];

    for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
        int index = i - Calendar.SUNDAY;

        mDayStrsLong[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_LONG).toUpperCase();
        mDayStrsLong[index + 7] = mDayStrsLong[index];
        // e.g. Tue for Tuesday
        mDayStrs[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM).toUpperCase();
        mDayStrs[index + 7] = mDayStrs[index];
        // e.g. Tu for Tuesday
        mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORT).toUpperCase();

        // If we don't have 2-letter day strings, fall back to 1-letter.
        if (mDayStrs2Letter[index].equals(mDayStrs[index])) {
            mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORTEST);
        }

        mDayStrs2Letter[index + 7] = mDayStrs2Letter[index];
    }

    // Figure out how much space we need for the 3-letter abbrev names
    // in the worst case.
    p.setTextSize(DATE_HEADER_FONT_SIZE);
    p.setTypeface(mBold);
    String[] dateStrs = { " 28", " 30" };
    mDateStrWidth = computeMaxStringWidth(0, dateStrs, p);
    Time time = new Time();
    time.setJulianDay(mFirstJulianDay);
    String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false)));
    mDateStrWidthLong = computeMaxStringWidth(0, new String[] { s }, p);
    p.setTextSize(DAY_HEADER_FONT_SIZE);
    mDateStrWidth += computeMaxStringWidth(0, mDayStrs, p);
    mDateStrWidthLong += computeMaxStringWidth(0, mDayStrsLong, p);

    p.setTextSize(HOURS_TEXT_SIZE);
    p.setTypeface(null);
    handleOnResume();

    mAmString = DateUtils.getAMPMString(Calendar.AM).toUpperCase();
    mPmString = DateUtils.getAMPMString(Calendar.PM).toUpperCase();
    String[] ampm = { mAmString, mPmString };
    p.setTextSize(AMPM_TEXT_SIZE);
    mHoursWidth = Math.max(HOURS_MARGIN, computeMaxStringWidth(mHoursWidth, ampm, p) + HOURS_RIGHT_MARGIN);
    mHoursWidth = Math.max(MIN_HOURS_WIDTH, mHoursWidth);

    LayoutInflater inflater;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Resources.Theme dialogTheme = getResources().newTheme();
    dialogTheme.applyStyle(android.R.style.Theme_Dialog, true);
    TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground });

    // Catch long clicks for creating a new event
    mBaseDate = new Time(DayUtils.getTimeZone(context, mTZUpdater));
    long millis = System.currentTimeMillis();
    mBaseDate.set(millis);

    mEarliestStartHour = new int[mNumDays];
    mHasAllDayEvent = new boolean[mNumDays];

    // mLines is the array of points used with Canvas.drawLines() in
    // drawGridBackground() and drawAllDayEvents().  Its size depends
    // on the max number of lines that can ever be drawn by any single
    // drawLines() call in either of those methods.
    final int maxGridLines = (24 + 1) // max horizontal lines we might draw
            + (mNumDays + 1); // max vertical lines we might draw
    mLines = new float[maxGridLines * 4];
}

From source file:org.squale.welcom.outils.DateUtil.java

/**
 * @param beginDate date de dbut de la priode en Date
 * @param endDate date de fin de la priode en Date
 * @param weekend true pour que les jours fris tombant un week end soient comtabilis, false sinon.
 * @return retourne le nombre de jours fris dans la priode.
 *//*ww  w. ja va  2 s  .  c  o m*/
public static int getNbPublicHolliday(final Date beginDate, final Date endDate, final boolean weekend) {
    if ((beginDate == null) || (endDate == null)) {
        return 0;
    }
    final GregorianCalendar gc = new GregorianCalendar();
    // recupere l'anne de debut
    int by = getYearOfDate(gc, beginDate);

    // Recupere l'anne de fin
    int ey = getYearOfDate(gc, endDate);

    // Recupere les jours de vacance des 2 annes
    ArrayList ph = getPublicHolliday(by, ey);

    int nbph = 0;

    for (final Iterator iter = ph.iterator(); iter.hasNext();) {
        final Date d = (Date) iter.next();
        gc.setTime(d);

        // Si les WEEK-END sont compatbili , les ajouter au compteur
        if (weekend) {
            if (isBetween(d, beginDate, endDate)) {
                nbph++;
            }
        } else {
            // Verifie que ce n'est pas un Samedi ou un dimance pour ompatibilit
            if ((gc.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY)
                    && (gc.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY)) {
                if (isBetween(d, beginDate, endDate)) {
                    nbph++;
                }
            }
        }
    }

    return nbph;
}

From source file:com.layernet.thaidatetimepicker.date.MonthView.java

/**
 * Return a 1 or 2 letter String for use as a weekday label
 *
 * @param day The day for which to generate a label
 * @return The weekday label/*from w  w  w  .j  av  a 2  s.  co  m*/
 */
private String getWeekDayLabel(Calendar day) {

    // Localised short version of the string is not available on API < 18
    if (Build.VERSION.SDK_INT < 18) {
        String dayName = new SimpleDateFormat("E", locale).format(day.getTime());
        String dayLabel = dayName.substring(0, 1);

        // Thai labels should select 1 or 2 letter
        if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY
                || mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) {
            dayLabel = dayName.substring(0, 1);
        } else {
            dayName.substring(0, 2);
        }

        return dayLabel;
    }
    // Getting the short label is a one liner on API >= 18
    return new SimpleDateFormat("EEEEE", locale).format(day.getTime());
}

From source file:org.kuali.kra.committee.web.CommitteeScheduleAddSeleniumTest.java

/**
 * Determines whether the given {@code date} is on a weekday.
 * /* w  w w .  j  a va2 s  . c o m*/
 * @param date the date to check
 * @return true if {@code date} is on a weekday, false if it is on a weekend
 */
private boolean isWeekday(Date date) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);

    boolean isSaturday = calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY;
    boolean isSunday = calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY;

    return !isSaturday && !isSunday;
}

From source file:org.eevolution.form.VCRP.java

public CategoryDataset createDataset(Timestamp start, MResource r) {
    //System.out.println("Create new data set");
    GregorianCalendar gc1 = new GregorianCalendar();
    gc1.setTimeInMillis(start.getTime());
    gc1.clear(Calendar.MILLISECOND);
    gc1.clear(Calendar.SECOND);/* w  w  w . j a va  2 s . c om*/
    gc1.clear(Calendar.MINUTE);
    gc1.clear(Calendar.HOUR_OF_DAY);

    Timestamp date = start;
    String namecapacity = Msg.translate(Env.getCtx(), "Capacity");
    System.out.println("\n Namecapacity :" + namecapacity);
    String nameload = Msg.translate(Env.getCtx(), "Load");
    System.out.println("\n Nameload :" + nameload);
    String namesummary = Msg.translate(Env.getCtx(), "Summary");
    System.out.println("\n Namesummary :" + namesummary);
    MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null);
    System.out.println("\n Resourcetype " + t);
    int days = 1;
    long hours = 0;

    if (t.isTimeSlot()) {

        hours = MMPCMRP.getHoursAvailable(t.getTimeSlotStart(), t.getTimeSlotEnd());

    } else {
        //fjviejo e-evolution MachineQty
        if (r.getDailyCapacity().multiply(r.getMachineQty()).compareTo(Env.ZERO) != 0)
            hours = r.getDailyCapacity().multiply(r.getMachineQty()).longValue();
        else
            //fjviejo e-evolution end
            hours = 24;
    }
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //      Long Hours = new Long(hours);
    int C_UOM_ID = DB.getSQLValue(null, "SELECT C_UOM_ID FROM M_Product WHERE S_Resource_ID = ? ",
            r.getS_Resource_ID());
    MUOM uom = new MUOM(Env.getCtx(), C_UOM_ID, null);
    System.out.println("\n uom1 " + uom + "\n");
    //System.out.println("um.isHour()"+ uom.isHour() );
    if (!uom.isHour()) {
        System.out.println("\n uom2 " + uom + "\n");
        return dataset;
    }
    System.out.println("\n Dataset " + dataset + "\n");
    int summary = 0;
    //int cont = 1;
    DateFormat formatter = DateFormat.getDateInstance();

    /*
     *     Vit4B Modificado para que tome 28 dias y
     *
     *
     */

    while (days < 29) {
        /*
         *      VIT4B MODIFICACION PARA ACUMULADO DE DIAS
         *
         *
         *
                
                
        //System.out.println("Day Number" + days);
        String strday = formatter.format(date);
        //String day = new String(new Integer (date.getDate()).toString());
        String day = new String(formatter.format(date));
        //day = day.substring(0,5);
                
        int index = day.indexOf("/");
                
        String str = day.substring(0,index);
        System.out.println("str: " + str + " index de / " + index);
                
        String str2 = day.substring(index+1,day.length());
        System.out.println("str2 resto: " + str2);
                
        index = str2.indexOf("/");
        System.out.println(index);
                
        String str3 = str2.substring(0,index);
        System.out.println("str3: " + str3 + " index de / " + index);
                
        String str4 = str2.substring(index+1,str2.length());
        System.out.println(str4);
                
        System.out.println("dia: " + str);
        System.out.println("mes: " + str3);
        System.out.println("ao: " + str4);
                
        //day = str + str3;
                
        day = new String(str + str3);
                
                
        //day = day.substring(0,day.lastIndexOf("/"));
        //day =day.substring(0,3);
                
        //cont++;
                
        System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID());
        System.out.println("Date: "  +  date + " day: "  +  day);
        int seconds = getLoad(r.getS_Resource_ID(),date ,date);
        Long Hours = new Long(hours);
        System.out.println("Summary "+ summary);
        System.out.println("Capacity "+ hours);
        System.out.println("Load "+ seconds);
                
        /*
         *
         *      VIT4B MODIFICACION PARA ACUMULADO DE DIAS
         *
         *
         */

        /*
         *      ORIGINAL COMPIERE
         */

        String day = new String(new Integer(date.getDate()).toString());
        System.out.println("r.getS_Resource_ID()" + r.getS_Resource_ID());
        System.out.println("Date:" + date);

        /*
         *      VIT4B - Modificacin para calcular como se calcula el reporte CCRP
         *      en funcion de la carga parcial
         *
         *
         */

        int seconds = getLoad(r.getS_Resource_ID(), date, date);

        //BigDecimal value = calculateLoad(date, r, null);
        //int seconds = value.intValue();

        Long Hours = new Long(hours);
        System.out.println("Summary " + summary);
        System.out.println("Load " + seconds);

        /*
         *      FIN ORIGINAL COMPIERE
         *
         */

        switch (gc1.get(Calendar.DAY_OF_WEEK)) {
        case Calendar.SUNDAY:
            days++;
            if (t.isOnSunday()) { //System.out.println("si Sunday");
                                  //Msg.translate(Env.getCtx(), "OnSunday");
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (seconds / 3600); //+ (Hours.intValue() - ((seconds / 3600)));
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            } else { //System.out.println("no Sunday");
                     //String day = Msg.translate(Env.getCtx(), "OnSunday") ;
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            }
        case Calendar.MONDAY:
            days++;
            if (t.isOnMonday()) { //System.out.println("si Monday");
                                  //String day = Msg.translate(Env.getCtx(), "OnMonday") ;
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            } else {
                //System.out.println("no Monday");
                //String day = Msg.translate(Env.getCtx(), "OnMonday")  ;
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            }
        case Calendar.TUESDAY:
            days++;
            if (t.isOnTuesday()) { //System.out.println("si TuesDay");
                                   //String day = Msg.translate(Env.getCtx(), "OnTuesday");
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            } else {
                //System.out.println("no TuesDay");
                //String day = Msg.translate(Env.getCtx(), "OnTuesday");
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            }
        case Calendar.WEDNESDAY:
            days++;
            if (t.isOnWednesday()) {
                //String day = Msg.translate(Env.getCtx(), "OnWednesday");
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            } else {

                //String day = Msg.translate(Env.getCtx(), "OnWednesday");
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            }
        case Calendar.THURSDAY:
            days++;
            if (t.isOnThursday()) {
                //String day = Msg.translate(Env.getCtx(), "OnThursday");
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            } else {

                //String day = Msg.translate(Env.getCtx(), "OnThursday");
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            }
        case Calendar.FRIDAY:
            days++;
            if (t.isOnFriday()) {
                //String day = Msg.translate(Env.getCtx(), "OnFriday");
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            } else {

                //String day = Msg.translate(Env.getCtx(), "OnFriday");
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            }
        case Calendar.SATURDAY:
            days++;
            if (t.isOnSaturday()) {
                //String day = Msg.translate(Env.getCtx(), "OnSaturday");
                dataset.addValue(hours, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary + Hours.intValue() - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            } else {
                //String day = Msg.translate(Env.getCtx(), "OnSaturday");
                dataset.addValue(0, namecapacity, day);
                dataset.addValue(seconds / 3600, nameload, day);
                dataset.addValue(summary, namesummary, day);
                summary = summary - (seconds / 3600);
                gc1.add(Calendar.DATE, 1);
                date = org.compiere.util.TimeUtil.addDays(date, 1);
                break;
            }
        }

    }
    return dataset;
}