List of usage examples for java.util Calendar DAY_OF_WEEK
int DAY_OF_WEEK
To view the source code for java.util Calendar DAY_OF_WEEK.
Click Source Link
get
and set
indicating the day of the week. From source file:com.project.framework.util.DateUtils.java
/** * ??(?)./*from ww w . j ava 2s. c o m*/ * * @param date ? * @return Date ?? */ public static Date getBeforeTrad(Date date) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); do { calendar.roll(Calendar.DATE, false); } while (calendar.get(Calendar.DAY_OF_WEEK) == 1 || calendar.get(Calendar.DAY_OF_WEEK) == 7); return calendar.getTime(); }
From source file:net.firejack.platform.core.utils.DateUtils.java
/** * Increments the date to round it on week level * @param date - date to be incremented/*from www . ja v a 2s . c o m*/ * @return incremented date */ public static Date ceilDateToWeek(Date date) { date = addWeeks(date, 1); Calendar cal = new GregorianCalendar(); cal.setTime(date); while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { cal.add(Calendar.DAY_OF_MONTH, -1); } cal.set(Calendar.HOUR, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); return addMinutes(cal.getTime(), -1); }
From source file:net.kamhon.ieagle.util.DateUtil.java
public static boolean isSaturday(Date date) { Calendar cal = setTime(date); return cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY; }
From source file:se.vgregion.portal.notes.calendar.mdc.controllers.MyDayCalendarViewController.java
CalendarEventsPeriod makeDisplayPeriod(Date now) { Calendar c = Calendar.getInstance(); c.setTime(now);/* w w w .j a v a2 s . c o m*/ int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); DateTime startDate = new DateTime(now).withDayOfWeek(dayOfWeek - 1).withHourOfDay(0).withMinuteOfHour(0) .withSecondOfMinute(0).withMillisOfSecond(0); CalendarEventsPeriod displayPeriod = new CalendarEventsPeriod(startDate, CalendarEventsPeriod.ONE_DAY_PERIOD_LENGTH); return displayPeriod; }
From source file:net.sf.jasperreports.functions.standard.DateTimeFunctions.java
public Integer WEEKDAY(Object dateObject, Boolean isSundayFirstDay) { Integer dayOfWeek = getCalendarFieldFromDate(dateObject, Calendar.DAY_OF_WEEK); if (dayOfWeek == null) { if (log.isDebugEnabled()) { log.debug("Unable to get the correct day of the week."); }/*w w w . j av a 2 s . c om*/ return null; } if (isSundayFirstDay) { // By default Sunday is considered first day in Java // Calendar.SUNDAY should be a constant with value 1. // See the Calendar.DAY_OF_WEEK javadoc return dayOfWeek; } else { // shift the days if (dayOfWeek == Calendar.SUNDAY) { return 7; } else { return dayOfWeek - 1; } } }
From source file:net.diogobohm.timed.impl.ui.overviewwindow.OverviewWindowController.java
private Date getLastSunday(Date start) { Calendar calendar = Calendar.getInstance(); calendar.setTime(start);/* ww w .j a v a2s. c o m*/ while (calendar.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { calendar.setTime(DateUtils.addDays(calendar.getTime(), -1)); } return calendar.getTime(); }
From source file:com.linuxbox.enkive.statistics.gathering.past.PastGatherer.java
public void consolidatePastWeeks() { Calendar c = Calendar.getInstance(); c.setTime(statDate);// w ww. ja 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:moller.javapeg.program.gui.frames.ImageRepositoryStatisticsViewer.java
private Component createWeekDayStatistics() { int[] weekdays = new int[] { 0, 0, 0, 0, 0, 0, 0 }; ImageMetaDataContext imdc = ImageMetaDataContext.getInstance(); Calendar calendar = Calendar.getInstance(); Map<String, Long> dateTimeValues = imdc.getDateTimeValues(); for (String imagePath : dateTimeValues.keySet()) { calendar.setTimeInMillis(dateTimeValues.get(imagePath)); ++weekdays[calendar.get(Calendar.DAY_OF_WEEK) - 1]; }//from w w w . j a v a 2 s . co m DefaultCategoryDataset dataSet = new DefaultCategoryDataset(); String title = getLang().get("imagestatisticsviewer.chart.weekday.title"); for (int i = 0; i < weekdays.length; i++) { dataSet.setValue(weekdays[i], title, getWeekDayAsString(i + 1)); } return createChart(dataSet, title); }
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);//from ww w. ja v a 2 s.c om 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()); }