Example usage for java.util Calendar WEDNESDAY

List of usage examples for java.util Calendar WEDNESDAY

Introduction

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

Prototype

int WEDNESDAY

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

Click Source Link

Document

Value of the #DAY_OF_WEEK field indicating Wednesday.

Usage

From source file:TimeUtil.java

public static String dayStringFormat(long msecs) {
    GregorianCalendar cal = new GregorianCalendar();

    cal.setTime(new Date(msecs));

    int dow = cal.get(Calendar.DAY_OF_WEEK);

    switch (dow) {
    case Calendar.MONDAY:
        return "Monday";
    case Calendar.TUESDAY:
        return "Tuesday";
    case Calendar.WEDNESDAY:
        return "Wednesday";
    case Calendar.THURSDAY:
        return "Thursday";
    case Calendar.FRIDAY:
        return "Friday";
    case Calendar.SATURDAY:
        return "Saturday";
    case Calendar.SUNDAY:
        return "Sunday";
    }//w  ww.  j a va2s.c  o m

    return "Unknown";
}

From source file:org.exoplatform.addons.sdpDemo.populator.services.Utils.java

/**
 * Gets the day as int.//from   www.j  a  v  a  2  s  . c  o m
 *
 * @param day the day
 * @return the day as int
 */
public static int getDayAsInt(String day) {
    if ("monday".equals(day))
        return Calendar.MONDAY;
    else if ("tuesday".equals(day))
        return Calendar.TUESDAY;
    else if ("wednesday".equals(day))
        return Calendar.WEDNESDAY;
    else if ("thursday".equals(day))
        return Calendar.THURSDAY;
    else if ("friday".equals(day))
        return Calendar.FRIDAY;
    else if ("saturday".equals(day))
        return Calendar.SATURDAY;
    else if ("sunday".equals(day))
        return Calendar.SUNDAY;
    return Calendar.MONDAY;
}

From source file:org.kuali.student.r2.core.scheduling.util.SchedulingServiceUtil.java

/**
 * Converts a list of Calendar constants (i.e. Calendar.MONDAY, Calendar.FRIDAY) into a string of characters representing those days
 * Used in DTO/Entity translations for TimeSlot
 *
 * @param weekdaysList/*from  w w  w.  ja v a 2  s .com*/
 * @return
 */
public static String weekdaysList2WeekdaysString(List<Integer> weekdaysList) {
    StringBuilder result = new StringBuilder();

    for (Integer day : weekdaysList) {
        switch (day) {
        case Calendar.MONDAY: {
            result.append(SchedulingServiceConstants.MONDAY_TIMESLOT_DAY_CODE);
            break;
        }
        case Calendar.TUESDAY: {
            result.append(SchedulingServiceConstants.TUESDAY_TIMESLOT_DAY_CODE);
            break;
        }
        case Calendar.WEDNESDAY: {
            result.append(SchedulingServiceConstants.WEDNESDAY_TIMESLOT_DAY_CODE);
            break;
        }
        case Calendar.THURSDAY: {
            result.append(SchedulingServiceConstants.THURSDAY_TIMESLOT_DAY_CODE);
            break;
        }
        case Calendar.FRIDAY: {
            result.append(SchedulingServiceConstants.FRIDAY_TIMESLOT_DAY_CODE);
            break;
        }
        case Calendar.SATURDAY: {
            result.append(SchedulingServiceConstants.SATURDAY_TIMESLOT_DAY_CODE);
            break;
        }
        case Calendar.SUNDAY: {
            result.append(SchedulingServiceConstants.SUNDAY_TIMESLOT_DAY_CODE);
            break;
        }
        }
    }

    return result.toString();
}

From source file:com.binary_machinery.avalonschedule.view.schedule.SchedulePageFragment.java

@Nullable
@Override/*from   ww  w  .  j a v  a 2s .  c o 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:calendar.services.transformers.EntryToWeekRowTransformer.java

private BigDecimal setEntryToDayInWeekRow(Entry entry, WeekRow weekRow) {
    Date date = entry.getDate();//  w w  w  .  jav a 2 s .c  om
    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    Integer dayOfWeek = cal.get(Calendar.DAY_OF_WEEK);
    BigDecimal entryHours = entry.getHours();
    switch (cal.get(Calendar.DAY_OF_WEEK)) {
    case Calendar.SUNDAY:
        weekRow.setDay7Total(weekRow.getDay7Total().add(entryHours));
        weekRow.setDay7(entry.getDate());
        break;
    case Calendar.MONDAY:
        weekRow.setDay1Total(weekRow.getDay1Total().add(entryHours));
        weekRow.setDay1(entry.getDate());
        break;
    case Calendar.TUESDAY:
        weekRow.setDay2Total(weekRow.getDay2Total().add(entryHours));
        weekRow.setDay2(entry.getDate());
        break;
    case Calendar.WEDNESDAY:
        weekRow.setDay3Total(weekRow.getDay3Total().add(entryHours));
        weekRow.setDay3(entry.getDate());
        break;
    case Calendar.THURSDAY:
        weekRow.setDay4Total(weekRow.getDay4Total().add(entryHours));
        weekRow.setDay4(entry.getDate());
        break;
    case Calendar.FRIDAY:
        weekRow.setDay5Total(weekRow.getDay5Total().add(entryHours));
        weekRow.setDay5(entry.getDate());
        break;
    case Calendar.SATURDAY:
        weekRow.setDay6Total(weekRow.getDay6Total().add(entryHours));
        weekRow.setDay6(entry.getDate());
        break;

    }

    return entryHours;
}

From source file:JapaneseCalendar.java

public void paintComponent(Graphics g) {
    int width = 400;
    int height = 400;

    Calendar cal = Calendar.getInstance(locale);
    cal.setTime(new Date());

    String header = cal.getDisplayName(Calendar.MONTH, Calendar.LONG, locale);
    header += " " + cal.get(Calendar.YEAR);

    FontMetrics fm = g.getFontMetrics();
    Insets insets = getInsets();/* w w w .j  a v a 2  s.  c  o  m*/
    g.setColor(Color.black);
    g.drawString(header, (width - fm.stringWidth(header)) / 2, insets.top + fm.getHeight());

    DateFormatSymbols dfs = new DateFormatSymbols(locale);
    String[] weekdayNames = dfs.getShortWeekdays();
    int fieldWidth = (width - insets.left - insets.right) / 7;
    g.drawString(weekdayNames[Calendar.SUNDAY],
            insets.left + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.SUNDAY])) / 2,
            insets.top + 3 * fm.getHeight());
    g.drawString(weekdayNames[Calendar.MONDAY],
            insets.left + fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.MONDAY])) / 2,
            insets.top + 3 * fm.getHeight());
    g.drawString(weekdayNames[Calendar.TUESDAY],
            insets.left + 2 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.TUESDAY])) / 2,
            insets.top + 3 * fm.getHeight());
    g.drawString(weekdayNames[Calendar.WEDNESDAY],
            insets.left + 3 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.WEDNESDAY])) / 2,
            insets.top + 3 * fm.getHeight());
    g.drawString(weekdayNames[Calendar.THURSDAY],
            insets.left + 4 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.THURSDAY])) / 2,
            insets.top + 3 * fm.getHeight());
    g.drawString(weekdayNames[Calendar.FRIDAY],
            insets.left + 5 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.FRIDAY])) / 2,
            insets.top + 3 * fm.getHeight());
    g.drawString(weekdayNames[Calendar.SATURDAY],
            insets.left + 6 * fieldWidth + (fieldWidth - fm.stringWidth(weekdayNames[Calendar.SATURDAY])) / 2,
            insets.top + 3 * fm.getHeight());

    int dom = cal.get(Calendar.DAY_OF_MONTH);
    cal.set(Calendar.DAY_OF_MONTH, 1);
    int col = 0;
    switch (cal.get(Calendar.DAY_OF_WEEK)) {
    case Calendar.MONDAY:
        col = 1;
        break;

    case Calendar.TUESDAY:
        col = 2;
        break;

    case Calendar.WEDNESDAY:
        col = 3;
        break;

    case Calendar.THURSDAY:
        col = 4;
        break;

    case Calendar.FRIDAY:
        col = 5;
        break;

    case Calendar.SATURDAY:
        col = 6;
    }
    cal.set(Calendar.DAY_OF_MONTH, dom);

    int row = 5 * fm.getHeight();
    for (int i = 1; i <= cal.getActualMaximum(Calendar.DAY_OF_MONTH); i++) {
        g.drawString("" + i, insets.left + fieldWidth * col + (fieldWidth - fm.stringWidth("" + i)) / 2, row);
        if (++col > 6) {
            col = 0;
            row += fm.getHeight();
        }
    }
}

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

private int getEquivalentDay(int day) {
    switch (day) {
    case Calendar.SUNDAY:
        day = 6;//from   ww  w.j  a v a  2 s.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.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);/* w ww.j a  v a 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:org.ohmage.reminders.types.time.TimeTrigDesc.java

private void initialize(boolean repeatStatus) {
    mIsRandomized = false;/*from   ww  w . j  a v a 2 s.  co 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.kuali.student.r2.core.scheduling.util.SchedulingServiceUtil.java

public static List<Integer> weekdaysString2WeekdaysList(String weekdaysString) {
    List<Integer> result = new ArrayList<Integer>();
    if (StringUtils.isNotBlank(weekdaysString)) {
        checkStringForDayCode(SchedulingServiceConstants.MONDAY_TIMESLOT_DAY_CODE, Calendar.MONDAY, result,
                weekdaysString);//w  w w. j  ava  2  s .  c  om
        checkStringForDayCode(SchedulingServiceConstants.TUESDAY_TIMESLOT_DAY_CODE, Calendar.TUESDAY, result,
                weekdaysString);
        checkStringForDayCode(SchedulingServiceConstants.WEDNESDAY_TIMESLOT_DAY_CODE, Calendar.WEDNESDAY,
                result, weekdaysString);
        checkStringForDayCode(SchedulingServiceConstants.THURSDAY_TIMESLOT_DAY_CODE, Calendar.THURSDAY, result,
                weekdaysString);
        checkStringForDayCode(SchedulingServiceConstants.FRIDAY_TIMESLOT_DAY_CODE, Calendar.FRIDAY, result,
                weekdaysString);
        checkStringForDayCode(SchedulingServiceConstants.SATURDAY_TIMESLOT_DAY_CODE, Calendar.SATURDAY, result,
                weekdaysString);
        checkStringForDayCode(SchedulingServiceConstants.SUNDAY_TIMESLOT_DAY_CODE, Calendar.SUNDAY, result,
                weekdaysString);
    }
    return result;
}