Example usage for java.util Calendar MONDAY

List of usage examples for java.util Calendar MONDAY

Introduction

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

Prototype

int MONDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Monday.

Usage

From source file:com.esofthead.mycollab.core.utils.DateTimeUtils.java

/**
 * /*from  w  ww. ja  v  a 2s.co m*/
 * @param date
 * @return array of two date elements, first is the first day of week, and
 *         the second is the end week date
 */
public static Date[] getBounceDateofWeek(Date date) {
    Calendar calendar = new GregorianCalendar();
    calendar.setFirstDayOfWeek(Calendar.MONDAY);
    calendar.setTime(date);
    calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    Date begin = calendar.getTime();

    calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    Date end = calendar.getTime();
    return new Date[] { begin, end };
}

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

/**
 * This method is used for getting day of week short description
 * /* www. ja v  a2  s  . c  o 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:org.projectforge.framework.configuration.ConfigXml.java

private void reset() {
    jiraConfig = null;//  ww  w .ja va  2  s . c o m
    jiraBrowseBaseUrl = null;
    telephoneSystemOperatorPanelUrl = null;
    currencySymbol = "";
    defaultLocale = Locale.ENGLISH;
    defaultTimeNotation = null;
    firstDayOfWeek = Calendar.MONDAY;
    setExcelDefaultPaperSize("DINA4");
    holidays = null;
    databaseDirectory = "database";
    loggingDirectory = "logs";
    workingDirectory = "work";
    tempDirectory = "tmp";
    cronExpressionHourlyJob = null;
    cronExpressionNightlyJob = null;
    cronExpressionMebPollingJob = null;
    accountingConfig = new AccountingConfig();
    accountingConfig.reset();
    contractTypes = null;
}

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  www . ja  va2  s  .  c  o m
        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);
     }//w w w . j a  va2  s  .  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:com.fdu.jira.plugin.gadget.timesheet.GroupTimeSheetResource.java

@GET
@AnonymousAllowed/*from  w  w  w . j  a  va 2 s .  co m*/
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTimesheet(@Context HttpServletRequest request,
        @QueryParam("targetGroup") String targetGroupName, @QueryParam("project") String project) {
    if (targetGroupName != null)
        try {
            // TIME-158 workaround: this must be handled by application server instead or this may be bug in Jira gadgets
            targetGroupName = new String(StringEscapeUtils.unescapeHtml(targetGroupName).getBytes("ISO-8859-1"),
                    applicationProperties.getEncoding());
        } catch (UnsupportedEncodingException e) {
            // safe to ignore
        }

    // Retrieve projectId
    Long projectId = null;
    try {
        projectId = Long.parseLong(project.substring(project.indexOf("-") + 1));
    } catch (NumberFormatException e) {
        // ignore, no project selected
    }
    // Retrieve the number of weeks to display in summary
    int numOfWeeks = ServletUtil.getIntParam(request, "numOfWeeks", 1);
    // Retrieve the week day that is to be a first day
    int reportingDay = ServletUtil.getIntParam(request, "reportingDay", Calendar.MONDAY);

    VelocityManager vm = ComponentManager.getInstance().getVelocityManager();
    try {
        return Response.ok(new TimeSheetRepresentation(
                vm.getBody("templates/grouptimesheet/", "group-timesheet.vm",
                        getVelocityParams(request, numOfWeeks, reportingDay, targetGroupName, projectId)),
                /* projiectOrFilterName */ null)).cacheControl(getNoCacheControl()).build();
    } catch (VelocityException e) {
        e.printStackTrace();
        return Response.serverError().build();
    }
}

From source file:edu.umm.radonc.ca_dash.model.TxInstanceFacade.java

public TreeMap<Date, SynchronizedDescriptiveStatistics> getWeeklySummaryStatsAbs(Date startDate, Date endDate,
        Long hospitalser, String filter, boolean includeWeekends, boolean ptflag, boolean scheduledFlag) {
    Calendar cal = new GregorianCalendar();
    TreeMap<Date, SynchronizedDescriptiveStatistics> retval = new TreeMap<>();

    //SET TO BEGINNING OF WK FOR ABSOLUTE CALC
    cal.setTime(startDate);//w ww  .j  a  va2  s .c  om
    cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    startDate = cal.getTime();

    List<Object[]> events = getDailyCounts(startDate, endDate, hospitalser, filter, false, ptflag,
            scheduledFlag);

    DateFormat df = new SimpleDateFormat("MM/dd/yy");
    cal.setTime(startDate);
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    int wk = cal.get(Calendar.WEEK_OF_YEAR);
    int mo = cal.get(Calendar.MONTH);
    int yr = cal.get(Calendar.YEAR);
    if (mo == Calendar.DECEMBER && wk == 1) {
        yr = yr + 1;
    } else if (mo == Calendar.JANUARY && wk == 52) {
        yr = yr - 1;
    }
    String currYrWk = yr + "-" + String.format("%02d", wk);
    //String prevYrWk = "";
    String prevYrWk = currYrWk;
    SynchronizedDescriptiveStatistics currStats = new SynchronizedDescriptiveStatistics();
    int i = 0;
    while (cal.getTime().before(endDate) && i < events.size()) {

        Object[] event = events.get(i);
        Date d = (Date) event[0];
        Long count = (Long) event[1];

        cal.setTime(d);
        cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        wk = cal.get(Calendar.WEEK_OF_YEAR);
        mo = cal.get(Calendar.MONTH);
        yr = cal.get(Calendar.YEAR);
        if (mo == Calendar.DECEMBER && wk == 1) {
            yr = yr + 1;
        } else if (mo == Calendar.JANUARY && wk == 52) {
            yr = yr - 1;
        }
        currYrWk = yr + "-" + String.format("%02d", wk);

        if (!(prevYrWk.equals(currYrWk))) {
            GregorianCalendar lastMon = new GregorianCalendar();
            lastMon.setTime(cal.getTime());
            lastMon.add(Calendar.DATE, -7);
            retval.put(lastMon.getTime(), currStats);
            currStats = new SynchronizedDescriptiveStatistics();
        }

        prevYrWk = currYrWk;

        currStats.addValue(count);
        i++;
    }
    retval.put(cal.getTime(), currStats);

    return retval;
}

From source file:com.feilong.core.date.DateUtilTest.java

/**
 * Test get first week of specify date year.
 *//*from  w w  w .j  a  v a2 s .c  o  m*/
@Test
public void testGetFirstWeekOfSpecifyDateYear() {
    logDate(DateUtil.getFirstWeekOfSpecifyDateYear(NOW, Calendar.FRIDAY));
    logDate(DateUtil.getFirstWeekOfSpecifyDateYear(NOW, Calendar.MONDAY));
}

From source file:org.fenixedu.academic.ui.struts.action.publico.RoomSiteViewerDispatchAction.java

public ActionForward roomViewer(ActionMapping mapping, ActionForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    String roomId = request.getParameter("roomId");
    String roomName = request.getParameter("roomName");
    if (roomId == null) {
        roomId = (String) request.getAttribute("roomId");
    }//from  w  w  w .ja  v a  2 s. c  o m
    if (roomName == null) {
        roomName = (String) request.getAttribute("roomName");

    }
    request.setAttribute("roomName", roomName);
    request.setAttribute("roomId", roomId);
    RoomKey roomKey = null;
    Space room = null;
    if (roomName != null || roomId != null) {
        if (roomName != null) {
            roomKey = new RoomKey(roomName);
        }
        if (roomId != null) {
            room = FenixFramework.getDomainObject(roomId);
            if (!FenixFramework.isDomainObjectValid(room)) {
                room = null;
            }
        }
        InfoSiteRoomTimeTable bodyComponent = new InfoSiteRoomTimeTable();
        DynaActionForm indexForm = (DynaActionForm) form;
        Integer indexWeek = (Integer) indexForm.get("indexWeek");
        // Integer executionPeriodID = (Integer)
        // indexForm.get("selectedExecutionPeriodID");
        String executionPeriodIDString = request.getParameter("selectedExecutionPeriodID");
        if (executionPeriodIDString == null) {
            executionPeriodIDString = (String) request.getAttribute("selectedExecutionPeriodID");
        }
        String executionPeriodID = (executionPeriodIDString != null) ? executionPeriodIDString : null;
        if (executionPeriodID == null) {
            try {
                // executionPeriodID = (Integer)
                // indexForm.get("selectedExecutionPeriodID");
                executionPeriodID = indexForm.get("selectedExecutionPeriodID").equals("") ? null
                        : (String) indexForm.get("selectedExecutionPeriodID");
            } catch (IllegalArgumentException ex) {
            }
        }
        Calendar today = new DateMidnight().toCalendar(null);
        ArrayList weeks = new ArrayList();

        InfoExecutionPeriod executionPeriod;
        if (executionPeriodID == null) {
            executionPeriod = ReadCurrentExecutionPeriod.run();
            executionPeriodID = executionPeriod.getExternalId();
            try {
                indexForm.set("selectedExecutionPeriodID", executionPeriod.getExternalId().toString());
            } catch (IllegalArgumentException ex) {
            }
        } else {
            executionPeriod = ReadExecutionPeriodByOID.run(executionPeriodID);
        }

        // weeks
        Calendar begin = Calendar.getInstance();
        begin.setTime(executionPeriod.getBeginDate());
        Calendar end = Calendar.getInstance();
        end.setTime(executionPeriod.getEndDate());
        ArrayList weeksLabelValueList = new ArrayList();
        begin.add(Calendar.DATE, Calendar.MONDAY - begin.get(Calendar.DAY_OF_WEEK));
        int i = 0;
        boolean selectedWeek = false;
        while (begin.before(end) || begin.before(Calendar.getInstance())) {
            Calendar day = Calendar.getInstance();
            day.setTimeInMillis(begin.getTimeInMillis());
            weeks.add(day);
            String beginWeekString = DateFormatUtils.format(begin.getTime(), "dd/MM/yyyy");
            begin.add(Calendar.DATE, 5);
            String endWeekString = DateFormatUtils.format(begin.getTime(), "dd/MM/yyyy");
            weeksLabelValueList.add(
                    new LabelValueBean(beginWeekString + " - " + endWeekString, new Integer(i).toString()));
            begin.add(Calendar.DATE, 2);
            if (!selectedWeek && indexWeek == null && Calendar.getInstance().before(begin)) {
                indexForm.set("indexWeek", new Integer(i));
                selectedWeek = true;
            }
            i++;
        }

        final Collection<ExecutionSemester> executionSemesters = rootDomainObject.getExecutionPeriodsSet();
        final List<LabelValueBean> executionPeriodLabelValueBeans = new ArrayList<LabelValueBean>();
        for (final ExecutionSemester ep : executionSemesters) {
            if (ep.getState().equals(PeriodState.OPEN) || ep.getState().equals(PeriodState.CURRENT)) {
                executionPeriodLabelValueBeans.add(new LabelValueBean(
                        ep.getName() + " " + ep.getExecutionYear().getYear(), ep.getExternalId().toString()));
            }
        }
        request.setAttribute(PresentationConstants.LABELLIST_EXECUTIONPERIOD, executionPeriodLabelValueBeans);

        request.setAttribute(PresentationConstants.LABELLIST_WEEKS, weeksLabelValueList);
        if (indexWeek != null) {
            final int xpto = indexWeek.intValue();
            if (xpto < weeks.size()) {
                today = (Calendar) weeks.get(xpto);
            } else {
                today = (Calendar) weeks.iterator().next();
                indexForm.set("indexWeek", new Integer(0));
            }
        }

        try {
            InfoSiteRoomTimeTable component = null;
            if (room != null) {
                component = run(room, today, executionPeriodID);
            } else {
                if (roomKey != null) {
                    component = run(roomKey, today, executionPeriodID);
                }
            }
            request.setAttribute("component", component);
        } catch (NonExistingServiceException e) {
            throw new NonExistingActionException(e);
        } catch (FenixServiceException e) {
            throw new FenixActionException(e);
        }
        return mapping.findForward("roomViewer");
    }
    throw new FenixActionException();

}

From source file:de.fhbingen.wbs.wpOverview.tabs.AvailabilityGraph.java

/**
 * Set the view to WEEK./*from  ww  w  . j a  v  a 2s . co  m*/
 */
private void setWeekView() {

    actualStart = (GregorianCalendar) actualDay.clone();
    actualStart.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    actualStart.set(Calendar.HOUR_OF_DAY, 0);
    actualStart.set(Calendar.MINUTE, 0);

    actualEnd = (GregorianCalendar) actualDay.clone();
    actualEnd.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    actualEnd.set(Calendar.HOUR_OF_DAY, 23);
    actualEnd.set(Calendar.MINUTE, 59);

    actualStart.add(Calendar.HOUR_OF_DAY, -1);
    actualEnd.add(Calendar.HOUR_OF_DAY, 1);

    actualView = WEEK;

    GregorianCalendar helper = (GregorianCalendar) actualEnd.clone();
    helper.add(Calendar.DATE, -1);

    makeChart(LocalizedStrings.getGeneralStrings().calendarWeekAbbreviation() + " "
            + new SimpleDateFormat("ww yyyy").format(helper.getTime()));
}