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.asta.app2.tutorial.helloorchestra.ReservationView.java
private boolean isAvailable(Date start, int days) { // the logic here would normally be on some "business service" class rather // than buried here inside the presentation class... // The hotel is closed on sat/sun nights. // Calendar.SUNDAY=1, SATURDAY=6 Calendar cal = Calendar.getInstance(); cal.setTime(start);/*from w w w. ja va2 s. com*/ int dow = cal.get(Calendar.DAY_OF_WEEK); if (dow == Calendar.SUNDAY) { return false; } if (dow + days > Calendar.SATURDAY) { return false; } // otherwise, ok return true; }
From source file:net.chrisrichardson.foodToGo.domain.hibernate.HibernateRestaurantRepositoryImpl.java
Object[] makeParameterValues(Address deliveryAddress, Date deliveryTime) { Calendar c = Calendar.getInstance(); c.setTime(deliveryTime);/*w w w .j av a 2s. com*/ int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); int timeOfDay = c.get(Calendar.HOUR_OF_DAY) * 100 + c.get(Calendar.MINUTE); String zipCode = deliveryAddress.getZip(); Object[] values = new Object[] { zipCode, new Integer(dayOfWeek), new Integer(timeOfDay) }; return values; }
From source file:com.ekom.ekomerp.global.DateTimeUtils.java
public static int getCalendarDayOfWeek(Date date) { return DateUtils.toCalendar(date).get(Calendar.DAY_OF_WEEK); }
From source file:net.sf.l2j.gameserver.model.entity.ClanHallSiege.java
public void setNewSiegeDate(long siegeDate, int ClanHallId, int hour) { Calendar tmpDate = Calendar.getInstance(); if (siegeDate <= System.currentTimeMillis()) { tmpDate.setTimeInMillis(System.currentTimeMillis()); tmpDate.add(Calendar.DAY_OF_MONTH, 3); tmpDate.set(Calendar.DAY_OF_WEEK, 6); tmpDate.set(Calendar.HOUR_OF_DAY, hour); tmpDate.set(Calendar.MINUTE, 0); tmpDate.set(Calendar.SECOND, 0); setSiegeDate(tmpDate);//from ww w. jav a 2s . co m Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con .prepareStatement("UPDATE clanhall_siege SET siege_data=? WHERE id = ?"); statement.setLong(1, getSiegeDate().getTimeInMillis()); statement.setInt(2, ClanHallId); statement.execute(); statement.close(); } catch (Exception e) { _log.error("Exception: can't save clanhall siege date: " + e.getMessage(), e); } finally { try { if (con != null) con.close(); } catch (SQLException e) { e.printStackTrace(); } } } }
From source file:net.rrm.ehour.ui.admin.config.MainConfigBackingBean.java
public MainConfigBackingBean(EhourConfigStub config) { this.config = config; smtpAuthentication = StringUtils.isNotBlank(config.getSmtpUsername()) && StringUtils.isNotBlank(config.getSmtpPassword()); Calendar cal = new GregorianCalendar(); DateUtil.dayOfWeekFix(cal);//from ww w.j ava 2s . co m cal.set(Calendar.DAY_OF_WEEK, config.getFirstDayOfWeek()); firstWeekStart = cal.getTime(); splitCronExpression(config.getReminderTime()); updateReminderCronExpression(); }
From source file:com.adobe.acs.commons.http.headers.impl.WeeklyExpiresHeaderFilterTest.java
@Test public void testAdjustExpiresPastWeekday() throws Exception { Calendar actual = Calendar.getInstance(); actual.set(Calendar.SECOND, 0); actual.set(Calendar.MILLISECOND, 0); Calendar expected = Calendar.getInstance(); expected.setTime(actual.getTime());//from ww w . ja v a 2 s. c om expected.add(Calendar.DAY_OF_WEEK, -3); expected.add(Calendar.DAY_OF_WEEK, 7); int dayOfWeek = expected.get(Calendar.DAY_OF_WEEK); properties.put(WeeklyExpiresHeaderFilter.PROP_EXPIRES_DAY_OF_WEEK, dayOfWeek); filter.doActivate(componentContext); filter.adjustExpires(actual); assertTrue(DateUtils.isSameInstant(expected, actual)); assertEquals(dayOfWeek, actual.get(Calendar.DAY_OF_WEEK)); }
From source file:net.chrisrichardson.foodToGo.placeOrderTransactionScripts.dao.RestaurantDAOIBatisImpl.java
public boolean isInServiceArea(String restaurantId, Address deliveryAddress, Date deliveryTime) { Calendar c = Calendar.getInstance(); c.setTime(deliveryTime);/* w w w. j a v a2s .co m*/ int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); String zipCode = deliveryAddress.getZip(); Map params = new HashMap(); params.put("zipCode", zipCode); params.put("dayOfWeek", new Integer(dayOfWeek)); params.put("deliveryTime", hour * 100 + minute); params.put("restaurantId", restaurantId); Object result = getSqlMapClientTemplate().queryForObject("isInServiceArea", params); return !new Integer(0).equals(result); }
From source file:org.atomspace.ultrahouse3000.translator.Message2DocumentTranslator.java
void addCalenderInformation(Message message) { Calendar cal = Calendar.getInstance(); message.setHeader("timestamp", cal.getTimeInMillis()); message.setHeader("calendarYear", cal.get(Calendar.YEAR)); message.setHeader("calendarDayOfMonth", cal.get(Calendar.DAY_OF_MONTH)); message.setHeader("calendarMonth", cal.get(Calendar.MONTH)); message.setHeader("calendarDayOfYear", cal.get(Calendar.DAY_OF_YEAR)); message.setHeader("calendarHourOfDay", cal.get(Calendar.HOUR_OF_DAY)); message.setHeader("calendarMinute", cal.get(Calendar.MINUTE)); message.setHeader("calendarSecond", cal.get(Calendar.SECOND)); message.setHeader("calendarWeekOfYear", cal.get(Calendar.WEEK_OF_YEAR)); message.setHeader("calendarDayOfWeek", cal.get(Calendar.DAY_OF_WEEK)); }
From source file:org.karndo.graphs.CustomChartFactory.java
/** * Creates a chart of the selected PiracyEvent data graphed by day-of-the- * week. Presently uses a very basic method of graphing this data by * using the static CreateBarChart3D method available in class * org.jfree.chart.ChartFactory. * //from w ww . ja v a 2 s. c o m * * @param data the selected PiracyEvent data to graph. * @return A JFreeChart object representing a graph of the selected * PiracyEvent data against days of the Calendar week. */ public JFreeChart createPiracyHistogramDayOfWeek(LinkedList<PiracyEvent> data) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Integer[] freqs = new Integer[DAYS_OF_THE_WEEK.length]; Calendar cal = Calendar.getInstance(); //set up the frequencies array for (int i = 0; i < freqs.length; i++) { freqs[i] = 0; } for (PiracyEvent ev : data) { cal.setTime(ev.getDate()); freqs[cal.get(Calendar.DAY_OF_WEEK) - 1]++; } //add the frequencies to a dataset for plotting for (int i = 0; i < freqs.length; i++) { dataset.addValue(freqs[i], "Piracy Incidents", DAYS_OF_THE_WEEK[i]); } JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by days of the week", "Day of the Week", "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false); return chart; }
From source file:com.example.android.myargmenuplanner.data.LoadMenu.java
@Override protected String[] doInBackground(String... params) { Uri mUri = MenuEntry.CONTENT_URI; Cursor mCursor = mContext.getContentResolver().query(mUri, null, null, null, null); if (mCursor.getCount() == 0) { int shift = 0; DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); String sDate = df.format(cal.getTime()); int dayofweek = cal.get(Calendar.DAY_OF_WEEK); Log.i(LOG_TAG, "Init Date: " + date); Vector<ContentValues> cVVector = new Vector<ContentValues>(14 - dayofweek); for (int i = dayofweek; i <= 14; i++) { ContentValues values = new ContentValues(); values.put(MenuEntry.COLUMN_DATE, sDate); values.put(MenuEntry.COLUMN_LUNCH, "Empty"); values.put(MenuEntry.COLUMN_ID_LUNCH, 0); values.put(MenuEntry.COLUMN_DINNER, "Empty"); values.put(MenuEntry.COLUMN_ID_DINNER, 0); cVVector.add(values);/*from w w w. j a va 2s. c o m*/ cal.add(Calendar.DATE, 1); sDate = df.format(cal.getTime()); // Log.i(LOG_TAG, "Day of the week: "+cal.get(Calendar.DAY_OF_WEEK)); // Log.i(LOG_TAG, "Date: "+date); } int inserted = 0; // // add to database Log.i(LOG_TAG, "Creando registros en base de datos. Tabla Menu "); if (cVVector.size() > 0) { ContentValues[] cvArray = new ContentValues[cVVector.size()]; cVVector.toArray(cvArray); inserted = mContext.getContentResolver().bulkInsert(MenuEntry.CONTENT_URI, cvArray); Log.i(LOG_TAG, "Registros nuevos creados en Tabla Menu: " + inserted); } } else { //ya tengo registros, tengo que fijarme las fechas DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); Calendar cal = Calendar.getInstance(); String dateNow = df.format(cal.getTime()); int dayofweek = cal.get(Calendar.DAY_OF_WEEK); String date = ""; String week = ""; while (mCursor.moveToNext()) { date = mCursor.getString(1); if (dateNow.equals(date)) { } } } return null; }