List of usage examples for java.util Calendar SUNDAY
int SUNDAY
To view the source code for java.util Calendar SUNDAY.
Click Source Link
From source file:net.diogobohm.timed.impl.ui.overviewwindow.OverviewWindowController.java
private Date getLastSunday(Date start) { Calendar calendar = Calendar.getInstance(); calendar.setTime(start);/*from w ww . ja v a 2 s .co m*/ while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { calendar.setTime(DateUtils.addDays(calendar.getTime(), -1)); } return calendar.getTime(); }
From source file:org.projectforge.calendar.DayHolder.java
public boolean isWeekend() { int dayOfWeek = getDayOfWeek(); return Calendar.SUNDAY == dayOfWeek || Calendar.SATURDAY == dayOfWeek; }
From source file:de.austinpadernale.holidays.Holiday.java
public void setDayOfWeek(Integer dayOfWeek) { if (dayOfWeek < Calendar.SUNDAY || dayOfWeek > Calendar.SATURDAY) { throw new InvalidArgumentException("dayOfWeek", "must be between 1 and 7"); }//from w w w . j a v a2 s . co m this.dayOfWeek = dayOfWeek; }
From source file:com.linuxbox.enkive.statistics.gathering.past.PastGatherer.java
public void consolidatePastWeeks() { Calendar c = Calendar.getInstance(); c.setTime(statDate);/* ww w .j a v a2 s . co m*/ c.set(Calendar.MILLISECOND, 0); c.set(Calendar.SECOND, 0); c.set(Calendar.MINUTE, 0); c.set(Calendar.HOUR_OF_DAY, 0); while (c.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { c.add(Calendar.DATE, -1); } setEndDate(CONSOLIDATION_WEEK); if (c.getTimeInMillis() > endDate.getTime()) { client.storeData(consolidatePast(CONSOLIDATION_WEEK, c)); } }
From source file:net.kamhon.ieagle.util.DateUtil.java
public static boolean isSunday(Date date) { Calendar cal = setTime(date); return cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY; }
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);/* w ww. ja v a2 s. com*/ 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:org.openmrs.web.servlet.SummaryServlet.java
/** * Churn through the request object and return a conglomerated patientSet * * @param request//from w w w . j ava 2s.c om * @param response * @return * @throws ServletException * @throws IOException */ private Cohort getPatientSet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { DateFormat dateFormat = Context.getDateFormat(); String startDateString = ServletRequestUtils.getStringParameter(request, "startDate", ""); String endDateString = ServletRequestUtils.getStringParameter(request, "endDate", ""); String locationString = ServletRequestUtils.getStringParameter(request, "location", ""); String identifierStrings = ServletRequestUtils.getStringParameter(request, "patientIdentifiers", ""); Cohort ps = new Cohort(); // get patients according to start/end "Return Visit Date" if ((startDateString.length() != 0) || (endDateString.length() != 0)) { Concept c = Context.getConceptService().getConcept(Integer.valueOf("5096")); // RETURN VISIT DATE Calendar cal = Calendar.getInstance(); Date startDate; Date endDate; if (startDateString.length() != 0) { try { cal.setTime(dateFormat.parse(startDateString)); } catch (ParseException e) { throw new ServletException("Error parsing 'Start Date'", e); } } else { cal.setTime(new Date()); } // if they don't input an end date, assume they meant "this week" if ("".equals(endDateString)) { while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { cal.add(Calendar.DAY_OF_MONTH, -1); } startDate = cal.getTime(); cal.add(Calendar.DAY_OF_MONTH, 7); endDate = cal.getTime(); } else { // they put in an end date, assume literal start and end startDate = cal.getTime(); try { cal.setTime(dateFormat.parse(endDateString)); } catch (ParseException e) { throw new ServletException("Error parsing 'End Date'", e); } endDate = cal.getTime(); } ps = Cohort.union(ps, Context.getPatientSetService().getPatientsHavingDateObs(c.getConceptId(), startDate, endDate)); log.debug("PatientSet length after adding Return Visit obs: " + ps.size()); } // get all patients whose last encounter was at the given location if (locationString.length() > 0) { ps = Cohort.union(ps, Context.getPatientSetService().getPatientsHavingLocation(Integer.valueOf(locationString))); } List<String> identifiers = new Vector<String>(); // get patient identifiers from text box if (identifierStrings.length() > 0) { String[] stringArr = identifierStrings.split("\\s"); for (int x = 0; x < stringArr.length; x++) { String s = stringArr[x].trim(); if (s.length() > 0) { identifiers.add(s); } } } // if they submitted identifiers in the textarea or via a web submission if (identifiers.size() > 0) { ps = Cohort.union(ps, Context.getPatientSetService().convertPatientIdentifier(identifiers)); } return ps; }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting day of week short description * //from w w w . j av a 2 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.eevolution.form.CRP.java
/** * Create Category Dataset based on date start and resource * @param start// w ww . j ava 2 s.co m * @param resource * @return CategoryDataset */ protected CategoryDataset createDataset(Timestamp start, MResource resource) { GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND); gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); Timestamp date = start; String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); MResourceType t = MResourceType.get(Env.getCtx(), resource.getS_ResourceType_ID()); int days = 1; long hours = t.getTimeSlotHours(); 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 = ? ", resource.getS_Resource_ID()); MUOM uom = MUOM.get(Env.getCtx(), C_UOM_ID); if (!uom.isHour()) { return dataset; } long summary = 0; while (days < 32) { String day = new String(new Integer(date.getDate()).toString()); long HoursLoad = getLoad(resource, date).longValue(); Long Hours = new Long(hours); switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: days++; if (t.isOnSunday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.MONDAY: days++; if (t.isOnMonday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.TUESDAY: days++; if (t.isOnTuesday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.WEDNESDAY: days++; if (t.isOnWednesday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.THURSDAY: days++; if (t.isOnThursday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.FRIDAY: days++; if (t.isOnFriday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } case Calendar.SATURDAY: days++; if (t.isOnSaturday()) { dataset.addValue(hours, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary + Hours.intValue() - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } else { dataset.addValue(0, namecapacity, day); dataset.addValue(HoursLoad, nameload, day); dataset.addValue(summary, namesummary, day); summary = summary - (HoursLoad); gc1.add(Calendar.DATE, 1); date = new Timestamp(gc1.getTimeInMillis()); break; } } } return dataset; }
From source file:com.esofthead.mycollab.core.utils.DateTimeUtils.java
/** * //from www .j a va 2 s . c om * @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 }; }