Example usage for java.util Calendar SATURDAY

List of usage examples for java.util Calendar SATURDAY

Introduction

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

Prototype

int SATURDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Saturday.

Usage

From source file:org.openmrs.module.pharmacyapi.api.prescription.util.AbstractPrescriptionItemGenerator.java

public boolean isOrderExpired(final PrescriptionItem item, final Date creationDate) {

    final Double drugToPickUp = item.getDrugToPickUp();

    final Date nextPickUpDate = this.getNextPickUpDate(item.getDrugOrder());

    final Calendar calendar = Calendar.getInstance();
    calendar.setTime(nextPickUpDate);//ww w.j  a  v  a2  s  . c  o  m
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    calendar.add(Calendar.DAY_OF_MONTH, drugToPickUp.intValue());

    while ((calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)
            || (calendar.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)) {
        calendar.add(Calendar.DAY_OF_MONTH, -1);
    }

    return creationDate.after(calendar.getTime());
}

From source file:net.diogobohm.timed.impl.ui.overviewwindow.OverviewWindowController.java

private Date getNextSaturday(Date start) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(start);/*from  w  ww. j av  a  2  s.  c  om*/

    while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) {
        calendar.setTime(DateUtils.addDays(calendar.getTime(), 1));
    }

    return calendar.getTime();
}

From source file:com.clustercontrol.jobmanagement.factory.JobPlanSchedule.java

/**
 * ????Cron??//from  w w  w  .ja va2  s  .  c o m
 * 
 * @param cron
 */
private void createPlan(String cron) {

    /*
     * cron
     *       
     */

    // * 0 15 * * ? *         1500
    // * 0 23 ? * 1 *         2300
    // * */10 * * * ? *       10??

    String[] planSplit = cron.split(" ");
    String aster = "*";
    String question = "?";
    String slash = "/";
    if (!aster.equals(planSplit[0])) {
        secondType = 0;
        second = Integer.parseInt(planSplit[0]);
    }
    if (!aster.equals(planSplit[1])) {
        String[] slashSplit = planSplit[1].split(slash);
        int num = 0;
        for (String str : slashSplit) {
            m_log.trace("slashSplit[ " + num + " ] =" + str);
            num++;
        }
        //p?q????
        if (slashSplit.length == 2) {
            minuteType = 3;
            minute = Integer.parseInt(slashSplit[0]);
            fromMinutes = Integer.parseInt(slashSplit[0]);
            everyMinutes = Integer.parseInt(slashSplit[1]);
        } else {
            minuteType = 0;
            minute = Integer.parseInt(planSplit[1]);
            m_log.debug("minuteType=" + minuteType);
            m_log.debug("minute=" + minute);
        }
    }
    if (!aster.equals(planSplit[2])) {
        hourType = 0;
        hour = Integer.parseInt(planSplit[2]);
    }
    if (question.equals(planSplit[3])) {
        dayType = 2;
    } else if (!aster.equals(planSplit[3])) {
        dayType = 0;
        day = Integer.parseInt(planSplit[3]);
    }
    if (!aster.equals(planSplit[4])) {
        monthType = 0;
        month = Integer.parseInt(planSplit[4]);
    }
    if (question.equals(planSplit[5])) {
        weekType = 2;
    } else if (!aster.equals(planSplit[5])) {
        weekType = 0;
        week = Integer.parseInt(planSplit[5]);
    }
    switch (week) {
    case 1:
        weekCalendar = Calendar.SUNDAY;
        break;
    case 2:
        weekCalendar = Calendar.MONDAY;
        break;
    case 3:
        weekCalendar = Calendar.TUESDAY;
        break;
    case 4:
        weekCalendar = Calendar.WEDNESDAY;
        break;
    case 5:
        weekCalendar = Calendar.THURSDAY;
        break;
    case 6:
        weekCalendar = Calendar.FRIDAY;
        break;
    case 7:
        weekCalendar = Calendar.SATURDAY;
        break;
    default:
        weekCalendar = Calendar.SUNDAY;
    }
    // weekType?0??????????
    // ??????????*????0?? 
    if (weekType == 0 && isFireDayOfWeek() == false) {
        nextFireDay();
        if (hourType == 1) {
            hour = 0;
        }
    }
}

From source file:org.kuali.student.enrollment.class2.acal.dto.ExamPeriodWrapper.java

public List<Date> getExamPeriodDates() {
    List<Date> dates = new ArrayList<Date>();
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(this.examPeriodInfo.getStartDate());

    while (calendar.getTime().before(this.examPeriodInfo.getEndDate())) {
        Date resultado = calendar.getTime();
        Calendar cal = Calendar.getInstance();
        cal.setTime(resultado);//  www .  j a v  a 2 s.  c o m
        int weekday = cal.get(Calendar.DAY_OF_WEEK);
        if ((weekday == Calendar.SATURDAY && !this.excludeSaturday)
                || (weekday == Calendar.SUNDAY && !this.excludeSunday)) {
            dates.add(resultado);
        } else if ((weekday != Calendar.SATURDAY) && (weekday != Calendar.SUNDAY)) {
            dates.add(resultado);
        }

        calendar.add(Calendar.DATE, 1);
    }
    calendar.setTime(this.examPeriodInfo.getEndDate());
    Date finalDate = calendar.getTime();
    dates.add(finalDate);
    return dates;
}

From source file:com.philliphsu.clock2.alarms.Alarm.java

public long ringsAt() {
    // Always with respect to the current date and time
    Calendar calendar = new GregorianCalendar();
    calendar.set(Calendar.HOUR_OF_DAY, hour());
    calendar.set(Calendar.MINUTE, minutes());
    calendar.set(Calendar.SECOND, 0);
    calendar.set(Calendar.MILLISECOND, 0);

    long baseRingTime = calendar.getTimeInMillis();

    if (!hasRecurrence()) {
        if (baseRingTime <= System.currentTimeMillis()) {
            // The specified time has passed for today
            baseRingTime += TimeUnit.DAYS.toMillis(1);
        }/*from ww  w  .  ja v  a 2 s . c o m*/
        return baseRingTime;
    } else {
        // Compute the ring time just for the next closest recurring day.
        // Remember that day constants defined in the Calendar class are
        // not zero-based like ours, so we have to compensate with an offset
        // of magnitude one, with the appropriate sign based on the situation.
        int weekdayToday = calendar.get(Calendar.DAY_OF_WEEK);
        int numDaysFromToday = -1;

        for (int i = weekdayToday; i <= Calendar.SATURDAY; i++) {
            if (isRecurring(i - 1 /*match up with our day constant*/)) {
                if (i == weekdayToday) {
                    if (baseRingTime > System.currentTimeMillis()) {
                        // The normal ring time has not passed yet
                        numDaysFromToday = 0;
                        break;
                    }
                } else {
                    numDaysFromToday = i - weekdayToday;
                    break;
                }
            }
        }

        // Not computed yet
        if (numDaysFromToday < 0) {
            for (int i = Calendar.SUNDAY; i < weekdayToday; i++) {
                if (isRecurring(i - 1 /*match up with our day constant*/)) {
                    numDaysFromToday = Calendar.SATURDAY - weekdayToday + i;
                    break;
                }
            }
        }

        // Still not computed yet. The only recurring day is weekdayToday,
        // and its normal ring time has already passed.
        if (numDaysFromToday < 0 && isRecurring(weekdayToday - 1)
                && baseRingTime <= System.currentTimeMillis()) {
            numDaysFromToday = 7;
        }

        if (numDaysFromToday < 0)
            throw new IllegalStateException("How did we get here?");

        return baseRingTime + TimeUnit.DAYS.toMillis(numDaysFromToday);
    }
}

From source file:com.pressurelabs.flowopensource.TheHubActivity.java

private void generateDrawerGreeting(NavigationView view) {
    View header = view.getHeaderView(0);
    TextView greeting = (TextView) header.findViewById(R.id.ndrawer_date_greeting);
    String[] array = this.getResources().getStringArray(R.array.drawer_greeting);

    switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) {
    case Calendar.MONDAY:
        greeting.setText(array[0]);/*from  ww  w .j a  v a2  s.com*/
        break;

    case Calendar.TUESDAY:
        greeting.setText(array[1]);
        break;

    case Calendar.WEDNESDAY:
        greeting.setText(array[2]);
        break;
    case Calendar.THURSDAY:
        greeting.setText(array[3]);
        break;
    case Calendar.FRIDAY:
        greeting.setText(array[4]);
        break;
    case Calendar.SATURDAY:
        greeting.setText(array[5]);
        break;

    case Calendar.SUNDAY:
        greeting.setText(array[6]);
        break;

    default:
        greeting.setText(array[7]);
        break;

    }

}

From source file:com.eryansky.common.utils.SysUtils.java

public static String getNowDateStr() {
     String result = dateFormat(getNowDate(), CHS_DATEFORMAT);
     Calendar c = Calendar.getInstance();
     for (int i = 0; i < 8; i++) {
         c.add(Calendar.DAY_OF_MONTH, 1);
         @SuppressWarnings("unused")
         int e = c.get(Calendar.DAY_OF_WEEK);
     }//from   www  .j  a va 2s . c  om
     result += "  ";
     switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) {
     case Calendar.SUNDAY:
         return result + "";
     case Calendar.MONDAY:
         return result + "";
     case Calendar.TUESDAY:
         return result + "";
     case Calendar.WEDNESDAY:
         return result + "";
     case Calendar.THURSDAY:
         return result + "";
     case Calendar.FRIDAY:
         return result + "";
     case Calendar.SATURDAY:
         return result + "";
     default:
         return result;
     }
 }

From source file:org.betaconceptframework.astroboa.portal.utility.CalendarUtils.java

public Calendar[] getCurrentWeekendPeriod(TimeZone zone, Locale locale) {
    Calendar weekendStart = GregorianCalendar.getInstance(zone, locale);
    Calendar weekendEnd = GregorianCalendar.getInstance(zone, locale);

    // we will include Friday in the weekend
    int currentDayOfWeek = weekendStart.get(Calendar.DAY_OF_WEEK);

    if (currentDayOfWeek == Calendar.FRIDAY) {
        // set to SUNDAY
        weekendEnd.add(Calendar.DAY_OF_MONTH, 2);
    } else if (currentDayOfWeek == Calendar.SATURDAY) {
        // set to SUNDAY
        weekendEnd.add(Calendar.DAY_OF_MONTH, 1);
    } else if (currentDayOfWeek == Calendar.SUNDAY) {
        //Do nothing
    } else {// www  .  j  a va  2s .  co m
        while (weekendStart.get(Calendar.DAY_OF_WEEK) != Calendar.FRIDAY) {
            weekendStart.add(Calendar.DAY_OF_MONTH, 1);
            weekendEnd.add(Calendar.DAY_OF_MONTH, 1);
        }

        // now weekendStart and weekendEnd is FRIDAY and we 
        // set weekendEnd to SUNDAY
        weekendEnd.add(Calendar.DAY_OF_MONTH, 2);

    }

    setCalendarToStartOfDay(weekendStart);
    setCalendarToEndOfDay(weekendEnd);

    Calendar[] period = { weekendStart, weekendEnd };
    return period;
}

From source file:com.mb.framework.util.DateTimeUtil.java

/**
 * This method is used for getting day of week short description
 * /*  w w  w.ja  v  a2  s  .co  m*/
 * @param dayOfWeek
 * @return
 */
public static String getDayOfWeekShortDesc(int dayOfWeek) {
    String dayOfWeekShortDesc;

    switch (dayOfWeek) {
    case Calendar.SUNDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_SUNDAY;
        break;
    }
    case Calendar.MONDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_MONDAY;
        break;
    }
    case Calendar.TUESDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_TUESDAY;
        break;
    }
    case Calendar.WEDNESDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_WEDNESDAY;
        break;
    }
    case Calendar.THURSDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_THURSDAY;
        break;
    }
    case Calendar.FRIDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_FRIDAY;
        break;
    }
    case Calendar.SATURDAY: {
        dayOfWeekShortDesc = DateTimeConstants.SHORT_SATURDAY;
        break;
    }
    default: {
        dayOfWeekShortDesc = "";
        break;
    }
    }
    return dayOfWeekShortDesc;
}

From source file:br.com.transport.report.ManagerReportBean.java

/**
 * Retorna o ultimo dia da semana/*from  www .  ja  v a  2s  . c  o  m*/
 * @return
 */
private Calendar getLastCalendar() {

    Calendar end = GregorianCalendar.getInstance();
    end.setFirstDayOfWeek(Calendar.SUNDAY);
    end.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY);
    end.set(Calendar.HOUR_OF_DAY, 23);
    end.set(Calendar.MINUTE, 59);
    end.set(Calendar.SECOND, 59);
    end.setTime(end.getTime());

    return end;
}