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.binary_machinery.avalonschedule.view.schedule.SchedulePageFragment.java

@Nullable
@Override/*from   ww w .  j av  a2  s  .co m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.schedule_page, container, false);
    Bundle arguments = getArguments();

    FragmentManager fragmentManager = getChildFragmentManager();
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();

    Func2<Integer, Integer, ?> setRecord = (dayOfWeek, layoutId) -> {
        String key = ARG_DAY + dayOfWeek;
        ScheduleRecord record = arguments.getParcelable(key);

        if (record != null) {
            Fragment fragment = (record.course != null) ? new RecordFragment() : new EmptyRecordFragment();
            Bundle args = new Bundle();
            args.putParcelable(RecordFragment.ARG_RECORD, record);
            fragment.setArguments(args);
            fragmentTransaction.replace(layoutId, fragment);
        }

        return 0;
    };

    setRecord.call(Calendar.MONDAY, R.id.layoutMonday);
    setRecord.call(Calendar.TUESDAY, R.id.layoutTuesday);
    setRecord.call(Calendar.WEDNESDAY, R.id.layoutWednesday);
    setRecord.call(Calendar.THURSDAY, R.id.layoutThursday);
    setRecord.call(Calendar.FRIDAY, R.id.layoutFriday);
    setRecord.call(Calendar.SATURDAY, R.id.layoutSaturday);
    setRecord.call(Calendar.SUNDAY, R.id.layoutSunday);

    fragmentTransaction.commit();
    return rootView;
}

From source file:com.hurence.logisland.utils.DateUtils.java

/**
 * Compute the week number of parameter date
 *
 * @param date/*from  ww w  .  j a  v  a  2s. c  o  m*/
 * @return Week number : ex 13
 */
public static int getWeekNumberFromDate(Date date) {

    if (date != null) {
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.setTime(date);

        return calendar.get(Calendar.WEEK_OF_YEAR);
    } else {
        return 0;
    }
}

From source file:lineage2.gameserver.model.entity.events.impl.ClanHallAuctionEvent.java

/**
 * Method reCalcNextTime./*ww w  . j  a va 2 s  .  c  o  m*/
 * @param onStart boolean
 */
@Override
public void reCalcNextTime(boolean onStart) {
    clearActions();
    _onTimeActions.clear();

    Clan owner = getResidence().getOwner();

    _endSiegeDate.setTimeInMillis(0);
    if ((getResidence().getAuctionLength() == 0) && (owner == null)) {
        getResidence().getSiegeDate().setTimeInMillis(System.currentTimeMillis());
        getResidence().getSiegeDate().set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
        getResidence().getSiegeDate().set(Calendar.HOUR_OF_DAY, 15);
        getResidence().getSiegeDate().set(Calendar.MINUTE, 0);
        getResidence().getSiegeDate().set(Calendar.SECOND, 0);
        getResidence().getSiegeDate().set(Calendar.MILLISECOND, 0);

        getResidence().setAuctionLength(7);
        getResidence().setAuctionMinBid(getResidence().getBaseMinBid());
        getResidence().setJdbcState(JdbcEntityState.UPDATED);
        getResidence().update();

        _onTimeActions.clear();
        addOnTimeAction(0, new StartStopAction(EVENT, true));
        addOnTimeAction(getResidence().getAuctionLength() * 86400, new StartStopAction(EVENT, false));

        _endSiegeDate.setTimeInMillis(getResidence().getSiegeDate().getTimeInMillis()
                + (getResidence().getAuctionLength() * 86400000L));

        registerActions();
    } else if ((getResidence().getAuctionLength() == 0) && (owner != null)) {
    } else {
        long endDate = getResidence().getSiegeDate().getTimeInMillis()
                + (getResidence().getAuctionLength() * 86400000L);
        if (endDate <= System.currentTimeMillis()) {
            getResidence().getSiegeDate().setTimeInMillis(System.currentTimeMillis());
        }

        _endSiegeDate.setTimeInMillis(getResidence().getSiegeDate().getTimeInMillis()
                + (getResidence().getAuctionLength() * 86400000L));

        _onTimeActions.clear();
        addOnTimeAction(0, new StartStopAction(EVENT, true));
        addOnTimeAction(getResidence().getAuctionLength() * 86400, new StartStopAction(EVENT, false));

        registerActions();
    }
}

From source file:com.karthikb351.vitinfo2.fragment.schedule.ScheduleFragment.java

private int getEquivalentDay(int day) {
    switch (day) {
    case Calendar.SUNDAY:
        day = 6;/*from www .  j ava 2s .c  o  m*/
        break;
    case Calendar.MONDAY:
    case Calendar.TUESDAY:
    case Calendar.WEDNESDAY:
    case Calendar.THURSDAY:
    case Calendar.FRIDAY:
    case Calendar.SATURDAY:
        day -= 2;
        break;
    default:
        day = 0;
    }
    return day;
}

From source file:org.ohmage.reminders.types.time.TimeTrigDesc.java

private void initialize(boolean repeatStatus) {
    mIsRandomized = false;/*from   w  w w .  j a va2 s  .  c o m*/
    mIsRangeEnabled = false;

    mRepeatList.put(getDayOfWeekString(Calendar.SUNDAY), repeatStatus);
    mRepeatList.put(getDayOfWeekString(Calendar.MONDAY), repeatStatus);
    mRepeatList.put(getDayOfWeekString(Calendar.TUESDAY), repeatStatus);
    mRepeatList.put(getDayOfWeekString(Calendar.WEDNESDAY), repeatStatus);
    mRepeatList.put(getDayOfWeekString(Calendar.THURSDAY), repeatStatus);
    mRepeatList.put(getDayOfWeekString(Calendar.FRIDAY), repeatStatus);
    mRepeatList.put(getDayOfWeekString(Calendar.SATURDAY), repeatStatus);
}

From source file:org.openmrs.module.pihmalawi.reporting.definition.renderer.IC3TraceReportRenderer.java

@Override
public void render(ReportData reportData, String argument, OutputStream out)
        throws IOException, RenderingException {

    ExcelBuilder builder = new ExcelBuilder();
    Date reportDate = reportData.getContext().getEvaluationDate();

    Calendar nextMonday = ApzuReportUtil.nextDayOfWeek(reportDate, Calendar.MONDAY);
    Calendar nextSecondWednesday = ApzuReportUtil.nextDayOfWeek(reportDate, Calendar.WEDNESDAY);
    nextSecondWednesday.add(Calendar.DAY_OF_MONTH, 7);

    for (String key : reportData.getDataSets().keySet()) {
        SimpleDataSet ds = (SimpleDataSet) reportData.getDataSets().get(key);
        if (ds.getRows().size() > 0) {

            DataSetMetaData metaData = ds.getMetaData();
            Location location = getParameterValue(ds, ReportingConstants.LOCATION_PARAMETER, Location.class);
            Integer minWk = getParameterValue(ds, MIN_WEEKS_PARAM, Integer.class);
            Integer maxWk = getParameterValue(ds, MAX_WEEKS_PARAM, Integer.class);
            Boolean isPhase1 = ObjectUtil.nvl(getParameterValue(ds, PHASE_1_ONLY_PARAM, Boolean.class), false);

            builder.newSheet(key);/*from w w w .  ja  va 2  s  .  c  o m*/

            builder.hideGridlinesInCurrentSheet();
            builder.setLandscape();
            builder.fitColumnsToPage();

            Map<String, Object> headerCellValues = getHeaderCellValues(minWk, isPhase1);
            int lastColMerge = isPhase1 ? 9 : location != null ? 12 : 13;

            String topRowStyle = "bold,size=18,color=" + HSSFColor.WHITE.index + ",background-color="
                    + HSSFColor.BLACK.index;
            builder.addCell(headerCellValues.get("traceLabel"), topRowStyle).merge(5, 0);
            builder.addCell(headerCellValues.get("reportLabel"), topRowStyle).merge(lastColMerge, 0);
            builder.nextRow();

            if (location != null) {
                builder.addCell(location.getName(), "bold,size=22,color=" + HSSFColor.BLUE.index).merge(5, 0);
                builder.addCell(builder.createRichTextString("Instructions: ", "bold",
                        "For each patient listed here, verify using the mastercards whether they have truly missed an appointment. If they have really missed the appointment, please find the patient and record the outcome.If they have not missed an appointment, add client name and visit details to \"Mastercard Update\" report. ",
                        null, "Upper Neno: ", "bold", "Return all findings to Chisomo (0884784429). ", null,
                        "Lower Neno: ", "bold", "Return all findings to Maxwell (0884784429).", null),
                        "size=12,wraptext,valign=center").merge(lastColMerge, 5);
                builder.nextRow();

                builder.addCell(minWk + "- <" + maxWk + " weeks missed appointment", "bold");
                builder.nextRow();

                builder.addCell(builder.createRichTextString("Patient tracking for week of ", "bold",
                        DateUtil.formatDate(nextMonday.getTime(), "EEEE, dd-MMM-yyyy"),
                        "color=" + HSSFColor.BLUE.index + ",bold"), null);
                builder.nextRow();
                builder.addCell(builder.createRichTextString("Date Report Printed: ", "bold",
                        DateUtil.formatDate(reportDate, "EEEE, dd-MMM-yyyy"),
                        "color=" + HSSFColor.BLUE.index + ",bold"), null);
                builder.nextRow();
                builder.addCell(builder.createRichTextString("Date Report due back to Chisomo/Maxwell:  ",
                        "bold", DateUtil.formatDate(nextSecondWednesday.getTime(), "EEEE, dd-MMM-yyyy"),
                        "color=" + HSSFColor.BLUE.index + ",bold"), null);
            } else {
                builder.nextRow();
                builder.addCell("12 weeks missed appointment", "bold").merge(5, 0);
                builder.addCell(builder.createRichTextString("Instructions: ", "bold",
                        "When complete, return all findings to Chisomo (0884784429) in Upper Neno and Maxwell (0884784429) in Lower Neno",
                        null), "size=12,wraptext,valign=center").merge(lastColMerge, 2);
                builder.nextRow();
                builder.addCell(builder.createRichTextString("Date Report Printed: ", "bold",
                        DateUtil.formatDate(reportDate, "EEEE, dd-MMM-yyyy"),
                        "color=" + HSSFColor.BLUE.index + ",bold"), null).merge(5, 0);
            }
            builder.nextRow();
            builder.nextRow();

            String headerStyle1 = "bold,size=11,wraptext,border=top";
            String headerStyle2 = headerStyle1 + ",rotation=90";
            String headerStyle3 = headerStyle2 + ",size=8";

            builder.addCell("", null, 6);
            if (metaData.getColumn("parameter.location") != null) {
                builder.addCell("Facility", headerStyle1 + ",border=left", 20);
                builder.addCell("ARV#", headerStyle1);
            } else {
                builder.addCell("ARV#", headerStyle1 + ",border=left", 12);
            }
            if (metaData.getColumn("NCD_NUMBER") != null) {
                builder.addCell("NCD#", headerStyle1, 12);
            }
            builder.addCell("First", headerStyle1, 12);
            builder.addCell("Last", headerStyle1, 15);
            builder.addCell("Village", headerStyle1, 30);
            builder.addCell("VHW", headerStyle1, 20);
            if (metaData.getColumn("DIAGNOSES") != null) {
                builder.addCell("Diagnoses", headerStyle1, 20);
            }
            builder.addCell("Last IC3 Visit Date", headerStyle1, 18);
            builder.addCell("Last Visit Appt Date", headerStyle1, 18);
            builder.addCell("Weeks out of Care", headerStyle1, 8);
            if (metaData.getColumn("PRIORITY_PATIENT") != null) {
                builder.addCell("Priority Patient", headerStyle1, 8);
            }
            builder.addCell(builder.createRichTextString("Patient actually\nvisited clinic.", headerStyle2,
                    "\nComplete Mastercard Update", headerStyle3), headerStyle2, 8);
            builder.addCell("Transferred Out", headerStyle2, 4);
            builder.addCell("Died", headerStyle2, 4);
            builder.addCell("Stopped", headerStyle2, 4);
            builder.addCell("Missed Appt", headerStyle2, 4);
            builder.addCell("Patient Not Found", headerStyle2, 4);
            builder.addCell("Remarks", headerStyle1 + ",border=right", 25);

            // Set this row to repeat when printing on subsequent pages
            int rowNum = builder.getCurrentRowNum();
            int colNum = builder.getCurrentColNum();
            builder.getCurrentSheet().setRepeatingRows(new CellRangeAddress(rowNum, rowNum, 0, colNum));

            builder.nextRow();

            String rowStyle = "border=top";

            DataSetRowList rows = ds.getRows();
            for (int i = 0; i < rows.size(); i++) {
                builder.addCell(i + 1, "color=" + HSSFColor.GREY_50_PERCENT.index);
                DataSetRow row = rows.get(i);
                if (i + 1 == rows.size()) {
                    rowStyle += ",border=bottom";
                }
                if (metaData.getColumn("parameter.location") != null) {
                    Location facility = (Location) row.getColumnValue("parameter.location");
                    builder.addCell(facility.getName(), rowStyle + ",border=left");
                    builder.addCell(row.getColumnValue("ARV_NUMBER"), rowStyle);
                } else {
                    builder.addCell(row.getColumnValue("ARV_NUMBER"), rowStyle + ",border=left");
                }

                if (metaData.getColumn("NCD_NUMBER") != null) {
                    builder.addCell(row.getColumnValue("NCD_NUMBER"), rowStyle);
                }
                builder.addCell(row.getColumnValue("FIRST_NAME"), rowStyle);
                builder.addCell(row.getColumnValue("LAST_NAME"), rowStyle);
                builder.addCell(row.getColumnValue("VILLAGE"), rowStyle);
                builder.addCell(row.getColumnValue("VHW"), rowStyle);
                if (metaData.getColumn("DIAGNOSES") != null) {
                    builder.addCell(row.getColumnValue("DIAGNOSES"), rowStyle);
                }
                builder.addCell(row.getColumnValue("LAST_VISIT_DATE"), rowStyle + ",date");
                builder.addCell(row.getColumnValue("NEXT_APPT_DATE"), rowStyle + ",date");
                builder.addCell(row.getColumnValue("WEEKS_OUT_OF_CARE"), rowStyle + ",format=0.0");
                if (metaData.getColumn("PRIORITY_PATIENT") != null) {
                    Set<String> s = (Set<String>) row.getColumnValue("PRIORITY_PATIENT");
                    builder.addCell(s != null && !s.isEmpty() ? "!!!" : "",
                            rowStyle + ",color=" + HSSFColor.RED.index + ",align=center");
                }
                for (int j = 0; j < 6; j++) {
                    builder.addCell("?", rowStyle + ",align=center,size=18");
                }
                builder.addCell("", rowStyle + ",border=right");
                builder.nextRow();
            }
        }
    }

    builder.write(out);
}

From source file:verdandi.model.WeekSelectorModel.java

private String getDateValue() {
    StringBuffer buf = new StringBuffer();
    Calendar cal = (Calendar) parent.getCurrentWeek().clone();
    buf.append(WEEK_OF_YEAR_PREFIX);/*from  w ww.  j a v a  2 s .  co  m*/
    if (cal.get(Calendar.WEEK_OF_YEAR) < 10) {
        buf.append("0");
    }
    buf.append(cal.get(Calendar.WEEK_OF_YEAR));
    buf.append(": ");
    cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
    buf.append(dfmt.format(cal.getTime()));
    buf.append(" - ");
    cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY);
    buf.append(dfmt.format(cal.getTime()));
    return buf.toString();
}

From source file:com.huateng.ebank.framework.util.DateUtil.java

/**
* ?/*from   www .  j  a va 2s. c om*/
* 
*/
public static List getEndWeekDate(Date startDate, Date endDate, SimpleDateFormat sdf) {

    Calendar cal = Calendar.getInstance();
    int days = getDaysBetween(startDate, endDate);
    List list = new ArrayList<String>();
    for (int i = 1; i < days; i++) {
        startDate = getNextDay(startDate);
        cal.setTime(startDate);
        // ?????
        int dayWeek = cal.get(Calendar.DAY_OF_WEEK);// ?
        if (1 == dayWeek) {
            cal.add(Calendar.DAY_OF_MONTH, -1);
        }
        cal.setFirstDayOfWeek(Calendar.MONDAY);// 
        int day = cal.get(Calendar.DAY_OF_WEEK);// ?
        cal.add(Calendar.DATE, cal.getFirstDayOfWeek() - day);// ???
        String imptimeBegin = sdf.format(cal.getTime());
        cal.add(Calendar.DATE, 6);
        String imptimeEnd = sdf.format(cal.getTime());
        list.add(imptimeEnd);
    }
    // ??
    Set set = new HashSet();
    List newList = new ArrayList();
    for (Iterator iter = list.iterator(); iter.hasNext();) {
        Object element = iter.next();

        if (set.add(element))
            newList.add(element);
    }
    list.clear();
    list.addAll(newList);

    return newList;
}

From source file:com.hurence.logisland.utils.DateUtils.java

/**
 * Check if the date parameter occurs during a weekend.
 *
 * @return Current time in ISO-8601 format, e.g. : "2012-07-03T07:59:09.206 UTC"
 *///from   w w  w.j  ava 2  s  . c o  m
public static boolean isWeekend(Date date) {
    if (date != null) {
        Calendar calendar = Calendar.getInstance();
        calendar.setFirstDayOfWeek(Calendar.MONDAY);
        calendar.setTime(date);
        int dayOfTheWeek = calendar.get(Calendar.DAY_OF_WEEK);
        return dayOfTheWeek == Calendar.SATURDAY || dayOfTheWeek == Calendar.SUNDAY;
    } else {
        return false;
    }

}

From source file:org.callistasoftware.netcare.core.repository.HealthPlanRepositoryTest.java

ActivityDefinitionEntity createActivityDefinition(HealthPlanEntity healthPlan, UserEntity user) {
    Frequency freq = new Frequency();
    freq.setWeekFrequency(1);/*w  ww . j  a v a  2s  .  c o m*/
    FrequencyDay day = FrequencyDay.newFrequencyDay(Calendar.MONDAY);
    FrequencyTime time = FrequencyTime.unmarshal("10:00");
    day.addTime(time);

    final CountyCouncilEntity cc = ccRepo.save(CountyCouncilEntity.newEntity(CountyCouncil.STOCKHOLM));

    final ActivityCategoryEntity cat = this.catRepo.save(ActivityCategoryEntity.newEntity("Fysisk aktivitet"));
    final CareUnitEntity cu = this.cuRepo.save(CareUnitEntity.newEntity("hsa-id", cc));
    final ActivityTypeEntity type = ActivityTypeEntity.newEntity("test", cat, cu, AccessLevel.CAREUNIT);
    MeasurementTypeEntity.newEntity(type, "Distans", MeasurementValueType.SINGLE_VALUE,
            newMeasureUnit("m", "Meter", cc), false, 0);
    MeasurementTypeEntity.newEntity(type, "Vikt", MeasurementValueType.INTERVAL,
            newMeasureUnit("kg", "Kilogram", cc), true, 1);
    typeRepo.save(type);
    typeRepo.flush();

    return ActivityDefinitionEntity.newEntity(healthPlan, type, freq, user);
}