List of usage examples for java.util Calendar SATURDAY
int SATURDAY
To view the source code for java.util Calendar SATURDAY.
Click Source Link
From source file:org.hawkular.alerts.api.model.action.TimeConstraint.java
private int day(String sDay) { if (isEmpty(sDay)) { return -1; }/*from w ww . j a v a 2s. co m*/ if (sDay.length() < 3) { return -1; } String prefix = sDay.substring(0, 3).toLowerCase(); DAY d = DAY.fromString(prefix); if (d == null) { return -1; } switch (d) { case SUNDAY: return Calendar.SUNDAY; case MONDAY: return Calendar.MONDAY; case TUESDAY: return Calendar.TUESDAY; case WEDNESDAY: return Calendar.WEDNESDAY; case THURSDAY: return Calendar.THURSDAY; case FRIDAY: return Calendar.FRIDAY; case SATURDAY: return Calendar.SATURDAY; default: return -1; } }
From source file:org.eevolution.form.CRP.java
/** * Create Category Dataset based on Weight , date start and resource * @param start/*from www .j a va 2s . c om*/ * @param resource * @return CategoryDataset */ protected CategoryDataset createWeightDataset(Timestamp start, MResource rosource) { 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); String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namepossiblecapacity = "Possible Capacity"; MResourceType t = MResourceType.get(Env.getCtx(), rosource.getS_ResourceType_ID()); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); double currentweight = DB.getSQLValue(null, "SELECT SUM( (mo.qtyordered-mo.qtydelivered)*(SELECT mp.weight FROM M_Product mp WHERE mo.m_product_id=mp.m_product_id )) FROM PP_Order mo WHERE AD_Client_ID=?", rosource.getAD_Client_ID()); double dailyCapacity = rosource.getDailyCapacity().doubleValue(); double utilization = rosource.getPercentUtilization().doubleValue(); double summary = 0; int day = 0; while (day < 32) { day++; switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: if (t.isOnSunday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.MONDAY: if (t.isOnMonday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.TUESDAY: if (t.isOnTuesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.WEDNESDAY: if (t.isOnWednesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.THURSDAY: if (t.isOnThursday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.FRIDAY: if (t.isOnFriday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.SATURDAY: if (t.isOnSaturday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; } dataset.addValue(currentweight, nameload, new Integer(day)); dataset.addValue(summary, namesummary, new Integer(day)); gc1.add(Calendar.DATE, 1); } return dataset; }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
private boolean isActiveDate(Calendar cal) { int day = cal.get(Calendar.DAY_OF_WEEK); long timeSinceStart = cal.get(Calendar.HOUR_OF_DAY) * 3600000 + cal.get(Calendar.MINUTE) * 60000 + cal.get(Calendar.SECOND) * 1000; if (day == Calendar.SUNDAY) { return (timeSinceStart > this.sundayStart && timeSinceStart < this.sundayEnd); } else if (day == Calendar.MONDAY) { return (timeSinceStart > this.mondayStart && timeSinceStart < this.mondayEnd); } else if (day == Calendar.TUESDAY) { return (timeSinceStart > this.tuesdayStart && timeSinceStart < this.tuesdayEnd); } else if (day == Calendar.WEDNESDAY) { return (timeSinceStart > this.wednesdayStart && timeSinceStart < this.wednesdayEnd); } else if (day == Calendar.THURSDAY) { return (timeSinceStart > this.thursdayStart && timeSinceStart < this.thursdayEnd); } else if (day == Calendar.FRIDAY) { return (timeSinceStart > this.fridayStart && timeSinceStart < this.fridayEnd); } else if (day == Calendar.SATURDAY) { return (timeSinceStart > this.saturdayStart && timeSinceStart < this.saturdayEnd); } else {/*from ww w.jav a 2 s . co m*/ return false; } }
From source file:com.jdo.CloudContactUtils.java
public static String getDay() { int d = Calendar.getInstance().get(Calendar.DAY_OF_WEEK); String day = "sun"; switch (d) {//from www .ja v a 2 s . c o m case Calendar.SUNDAY: day = "sun"; break; case Calendar.MONDAY: day = "mon"; break; case Calendar.TUESDAY: day = "tue"; break; case Calendar.WEDNESDAY: day = "wed"; break; case Calendar.THURSDAY: day = "thu"; break; case Calendar.FRIDAY: day = "fri"; break; case Calendar.SATURDAY: day = "sat"; break; } return day; }
From source file:org.eevolution.form.VSCRP.java
public CategoryDataset createWeightDataset(Timestamp start, MResource r) { GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);/*www . java 2 s . c o m*/ gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namepossiblecapacity = "Possible Capacity"; MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); double currentweight = DB.getSQLValue(null, "Select SUM( (mo.qtyordered-mo.qtydelivered)*(Select mp.weight From m_product mp Where mo.m_product_id=mp.m_product_id ) )From mpc_order mo Where ad_client_id=?", r.getAD_Client_ID()); // fjviejo e-evolution machineqty capacidad por el numero de maquinas // double dailyCapacity = DB.getSQLValue(null,"Select dailycapacity From s_resource Where s_resource_id=?",r.getS_Resource_ID()); double dailyCapacity = DB.getSQLValue(null, "Select dailycapacity*MachineQty From s_resource Where s_resource_id=?", r.getS_Resource_ID()); System.out.println("***** Capacidad diaria " + dailyCapacity); // e-evolution end double utilization = DB.getSQLValue(null, "Select percentutillization From s_resource Where s_resource_id=?", r.getS_Resource_ID()); double summary = 0; int day = 0; while (day < 32) { day++; switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: if (t.isOnSunday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.MONDAY: if (t.isOnMonday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.TUESDAY: if (t.isOnTuesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.WEDNESDAY: if (t.isOnWednesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.THURSDAY: if (t.isOnThursday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.FRIDAY: if (t.isOnFriday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.SATURDAY: if (t.isOnSaturday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; } dataset.addValue(currentweight, nameload, new Integer(day)); dataset.addValue(summary, namesummary, new Integer(day)); gc1.add(Calendar.DATE, 1); } return dataset; }
From source file:org.eevolution.form.VCRP.java
public CategoryDataset createWeightDataset(Timestamp start, MResource r) { GregorianCalendar gc1 = new GregorianCalendar(); gc1.setTimeInMillis(start.getTime()); gc1.clear(Calendar.MILLISECOND); gc1.clear(Calendar.SECOND);/*from ww w . j a v a2 s .c o m*/ gc1.clear(Calendar.MINUTE); gc1.clear(Calendar.HOUR_OF_DAY); String namecapacity = Msg.translate(Env.getCtx(), "Capacity"); String nameload = Msg.translate(Env.getCtx(), "Load"); String namesummary = Msg.translate(Env.getCtx(), "Summary"); String namepossiblecapacity = "Possible Capacity"; MResourceType t = new MResourceType(Env.getCtx(), r.getS_ResourceType_ID(), null); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); double currentweight = DB.getSQLValue(null, "Select SUM( (mo.qtyordered-mo.qtydelivered)*(Select mp.weight From m_product mp Where mo.m_product_id=mp.m_product_id ) )From mpc_order mo Where ad_client_id=?", r.getAD_Client_ID()); // fjviejo e-evolution machineqty capacidad por el numero de maquinas // double dailyCapacity = DB.getSQLValue(null,"Select dailycapacity From s_resource Where s_resource_id=?",r.getS_Resource_ID()); double dailyCapacity = DB.getSQLValue(null, "Select dailycapacity*MachineQty From s_resource Where s_resource_id=?", r.getS_Resource_ID()); System.out.println("***** Capacidad diaria " + dailyCapacity); // e-evolution end double utilization = DB.getSQLValue(null, "Select percentutillization From s_resource Where s_resource_id=?", r.getS_Resource_ID()); double summary = 0; int day = 0; /* * Vit4B Modificado para que tome 28 dias y * * */ while (day < 29) { day++; switch (gc1.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: if (t.isOnSunday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.MONDAY: if (t.isOnMonday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.TUESDAY: if (t.isOnTuesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.WEDNESDAY: if (t.isOnWednesday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.THURSDAY: if (t.isOnThursday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.FRIDAY: if (t.isOnFriday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; case Calendar.SATURDAY: if (t.isOnSaturday()) { currentweight -= (dailyCapacity * utilization) / 100; summary += ((dailyCapacity * utilization) / 100); dataset.addValue(dailyCapacity, namepossiblecapacity, new Integer(day)); dataset.addValue((dailyCapacity * utilization) / 100, namecapacity, new Integer(day)); } else { dataset.addValue(0, namepossiblecapacity, new Integer(day)); dataset.addValue(0, namecapacity, new Integer(day)); } break; } dataset.addValue(currentweight, nameload, new Integer(day)); dataset.addValue(summary, namesummary, new Integer(day)); gc1.add(Calendar.DATE, 1); } return dataset; }
From source file:com.seajas.search.attender.service.attender.dao.ProfileDAO.java
/** * Find all notifiable subscribers from the given profile. * // www .ja v a2 s . co m * @param calendar * @param profile * @return List<ProfileSubscriber> */ public List<ProfileSubscriber> findNotifiableSubscribers(final Calendar calendar, final List<ProfileSubscriber> subscribers) { if (!calendar.getTimeZone().getID().equals("UTC")) throw new IllegalArgumentException( "The given calendar must have a UTC timezone (has " + calendar.getTimeZone().getID() + ")"); // Calculate the current time in UTC Integer currentHour = calendar.get(Calendar.HOUR_OF_DAY), currentMinute = calendar.get(Calendar.MINUTE), currentDay = calendar.get(Calendar.DAY_OF_WEEK); Date currentTime = new Date(calendar.getTimeInMillis()); // Return a list of all applicable subscribers for this profile List<ProfileSubscriber> result = new ArrayList<ProfileSubscriber>(); // Find all active profiles' confirmed subscribers whose notification preference fall within the current day and whose time // values are greater than or equal to the current hour / minute; then take 7 days for weekly updates, 1 for daily updates, // and 1 for weekdays where Saturday / Sunday are excluded for (ProfileSubscriber subscriber : subscribers) { Integer subscriberDay = subscriber.getNotificationDay(), subscriberHour = subscriber.getNotificationHour(), subscriberMinute = subscriber.getNotificationMinute(); Date lastNotification = subscriber.getLastNotification(); NotificationType subscriberType = subscriber.getNotificationType(); // Correct for the user-specific timezone TimeZone timeZone = TimeZone.getTimeZone(subscriber.getTimeZone()); // Take leap seconds into account, although we're not so precise to really care if (subscriberMinute != null) { subscriberMinute -= (int) ((timeZone.getOffset(calendar.getTimeInMillis()) % MILLISECONDS_PER_HOUR) / MILLISECONDS_PER_MINUTE); if (subscriberMinute < 0) { subscriberMinute += 60; subscriberHour--; } else if (subscriberMinute > 59) { subscriberMinute -= 60; subscriberHour++; } } if (subscriberHour != null) { subscriberHour -= (int) (timeZone.getOffset(calendar.getTimeInMillis()) / MILLISECONDS_PER_HOUR); if (subscriberHour < 0) { subscriberHour += 24; if (subscriberDay != null) subscriberDay--; } else if (subscriberHour > 23) { subscriberHour -= 24; if (subscriberDay != null) subscriberDay++; } } if (subscriberDay == -1) subscriberDay = 6; else if (subscriberDay == 7) subscriberDay = 0; // Now determine the actual applicability (last_notification is stored as a UTC date, so does not need to be converted) if (subscriber.getIsConfirmed() && ((subscriberType.equals(NotificationType.Weekly) && subscriberDay.equals(currentDay) && subscriberHour <= currentHour && subscriberMinute <= currentMinute && dateDifference(lastNotification, currentTime) >= 6) || (subscriberType.equals(NotificationType.Weekdays) && currentDay != Calendar.SATURDAY && currentDay != Calendar.SUNDAY && subscriberHour <= currentHour && subscriberMinute <= currentMinute && !DateUtils.isSameDay(lastNotification, currentTime)) || (subscriberType.equals(NotificationType.Daily) && subscriberHour <= currentHour && subscriberMinute <= currentMinute && !DateUtils.isSameDay(lastNotification, currentTime)))) { if (logger.isInfoEnabled()) logger.info("Adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' to be notified"); result.add(subscriber); } else if (logger.isDebugEnabled()) { if (!subscriber.getIsConfirmed()) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - not confirmed"); else if (subscriberType.equals(NotificationType.Direct)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - direct notifications are handled by search-enricher instances"); else if (subscriberType.equals(NotificationType.Weekly)) { if (!subscriberDay.equals(currentDay)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - weekly notification does not fall on current day"); if (!(subscriberHour <= currentHour && subscriberMinute <= currentMinute)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - weekly notification falls outside of current time"); if (!(dateDifference(lastNotification, currentTime) >= 6)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - weekly notification difference (in days) smaller than 7"); } else if (subscriberType.equals(NotificationType.Weekdays)) { if (!(currentDay != Calendar.SATURDAY && currentDay != Calendar.SUNDAY)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - weekday notification does not fall on weekday"); if (!(subscriberHour <= currentHour && subscriberMinute <= currentMinute)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - weekday notification falls outside of current time"); if (DateUtils.isSameDay(lastNotification, currentTime)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - weekday notification difference indicates a notification has already gone out today"); } else if (subscriberType.equals(NotificationType.Daily)) { if (!(subscriberHour <= currentHour && subscriberMinute <= currentMinute)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - daily notification falls outside of current time"); if (DateUtils.isSameDay(lastNotification, currentTime)) logger.debug("Not adding subscriber '" + subscriber.getUniqueId() + "' with e-mail '" + subscriber.getEmail() + "' - daily notification difference indicates a notification has already gone out today"); } } } return result; }
From source file:com.pukulab.puku0x.gscalendar.CalendarActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_calendar); // ?//from w ww . ja v a 2 s . c o m mBackKeyTimer = new CountDownTimer(2000, 2000) { @Override public void onTick(long millisUntilFinished) { } @Override public void onFinish() { mBackKeyPressed = false; } }; // ? Bundle extras = getIntent().getExtras(); // ? if (mLoginUser == null) { mLoginUser = (UserData) extras.getSerializable(ARGS_LOGIN_USER); } // if (mDisplayedUser == null) { mDisplayedUser = (UserData) extras.getSerializable(ARGS_DISPLAYED_USER); } // ? if (mDisplayedDate == null) { mDisplayedDate = (Date) extras.getSerializable(ARGS_DISPLAYED_DATE); mLastDisplayedDate = mDisplayedDate; } // ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { // ????????? if (mDisplayedUser.usid != null && !mDisplayedUser.usid.equals(mLoginUser.usid)) { actionBar.setDisplayHomeAsUpEnabled(true); } // actionBar.setTitle(mDisplayedUser.name); actionBar.setSubtitle(DateFormat.format(getString(R.string.date_year_month_day), mDisplayedDate)); } // Retrieve the CalendarView mCalendarView = (MultiCalendarView) findViewById(R.id.calendarView); mProgressBar = (ProgressBar) findViewById(R.id.pb_detail); //mScheduleLayout = (LinearLayout) findViewById(R.id.scheduleList); // ? mScheduleDataList = new ArrayList<>(); mDailyScheduleList = new ArrayList<>(); mDailyScheduleaListAdapter = new ScheduleDataAdapter(CalendarActivity.this, 0, mDailyScheduleList); mDailyScheduleListView = (ListView) findViewById(R.id.lv_schedule); mDailyScheduleListView.setAdapter(mDailyScheduleaListAdapter); mDailyScheduleListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ListView listView = (ListView) parent; Schedule schedule = (Schedule) listView.getItemAtPosition(position); // ??? mLastSchedule = new Schedule(schedule); // ?? Intent intent = DetailActivity.createIntent(CalendarActivity.this, mLoginUser, mDisplayedUser, schedule); int requestCode = DetailActivity.REQUEST_DETAIL; startActivityForResult(intent, requestCode); } }); // Set the first valid day final Calendar firstValidDay = Calendar.getInstance(); firstValidDay.add(Calendar.YEAR, -1); firstValidDay.set(Calendar.DAY_OF_MONTH, 1); firstValidDay.set(Calendar.HOUR_OF_DAY, 0); firstValidDay.set(Calendar.MINUTE, 0); firstValidDay.set(Calendar.SECOND, 0); firstValidDay.set(Calendar.MILLISECOND, 0); mCalendarView.setFirstValidDay(firstValidDay); // Set the last valid day final Calendar lastValidDay = Calendar.getInstance(); lastValidDay.add(Calendar.YEAR, 1); lastValidDay.set(Calendar.HOUR_OF_DAY, 0); lastValidDay.set(Calendar.MINUTE, 0); lastValidDay.set(Calendar.SECOND, 0); lastValidDay.set(Calendar.MILLISECOND, 0); mCalendarView.setLastValidDay(lastValidDay); // ~ mCalendarView.setFirstDayOfWeek(Calendar.SUNDAY); mCalendarView.setLastDayOfWeek(Calendar.SATURDAY); // Create adapter final CustomDayAdapter adapter = new CustomDayAdapter(); // Set listener and adapter mCalendarView.setOnDayClickListener(this); mCalendarView.getIndicator().setOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { } @Override public void onPageSelected(int position) { //System.out.println("position:" + position); final Calendar cal = Calendar.getInstance(); cal.setTimeInMillis((mCalendarView.getFirstValidDay().getTimeInMillis())); cal.add(Calendar.MONTH, position); mStartDate = cal.getTime(); cal.add(Calendar.MONTH, 1); mEndDate = cal.getTime(); mViewPagerPosition = position; new DisplaySchedulesTask(CalendarActivity.this, mDisplayedUser, mDisplayedDate).execute(mStartDate, mEndDate); } @Override public void onPageScrollStateChanged(int state) { } }); mCalendarView.setDayAdapter(adapter); // ???????? mCalendarView.setViewPagerPosition(12); }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
private boolean isActiveDate(Calendar cal, Calendar cal2) { int day = cal.get(Calendar.DAY_OF_WEEK); long timeSinceStart = cal.get(Calendar.HOUR_OF_DAY) * 3600000 + cal.get(Calendar.MINUTE) * 60000 + cal.get(Calendar.SECOND) * 1000; boolean firstDate = false; if (day == Calendar.SUNDAY) { firstDate = (timeSinceStart > this.sundayStart && timeSinceStart < this.sundayEnd); } else if (day == Calendar.MONDAY) { firstDate = (timeSinceStart > this.mondayStart && timeSinceStart < this.mondayEnd); } else if (day == Calendar.TUESDAY) { firstDate = (timeSinceStart > this.tuesdayStart && timeSinceStart < this.tuesdayEnd); } else if (day == Calendar.WEDNESDAY) { firstDate = (timeSinceStart > this.wednesdayStart && timeSinceStart < this.wednesdayEnd); } else if (day == Calendar.THURSDAY) { firstDate = (timeSinceStart > this.thursdayStart && timeSinceStart < this.thursdayEnd); } else if (day == Calendar.FRIDAY) { firstDate = (timeSinceStart > this.fridayStart && timeSinceStart < this.fridayEnd); } else if (day == Calendar.SATURDAY) { firstDate = (timeSinceStart > this.saturdayStart && timeSinceStart < this.saturdayEnd); } else {/*w ww. j av a 2 s.c o m*/ firstDate = false; } int day2 = cal2.get(Calendar.DAY_OF_WEEK); timeSinceStart = cal2.get(Calendar.HOUR_OF_DAY) * 3600000 + cal2.get(Calendar.MINUTE) * 60000 + cal2.get(Calendar.SECOND) * 1000; boolean secondDate = false; if (day2 == Calendar.SUNDAY) { secondDate = (timeSinceStart > this.sundayStart && timeSinceStart < this.sundayEnd); } else if (day2 == Calendar.MONDAY) { secondDate = (timeSinceStart > this.mondayStart && timeSinceStart < this.mondayEnd); } else if (day2 == Calendar.TUESDAY) { secondDate = (timeSinceStart > this.tuesdayStart && timeSinceStart < this.tuesdayEnd); } else if (day2 == Calendar.WEDNESDAY) { secondDate = (timeSinceStart > this.wednesdayStart && timeSinceStart < this.wednesdayEnd); } else if (day2 == Calendar.THURSDAY) { secondDate = (timeSinceStart > this.thursdayStart && timeSinceStart < this.thursdayEnd); } else if (day2 == Calendar.FRIDAY) { secondDate = (timeSinceStart > this.fridayStart && timeSinceStart < this.fridayEnd); } else if (day2 == Calendar.SATURDAY) { secondDate = (timeSinceStart > this.saturdayStart && timeSinceStart < this.saturdayEnd); } else { secondDate = false; } return (firstDate && secondDate); }
From source file:com.borax12.materialdaterangepicker.date.MonthView.java
protected void drawMonthDayLabels(Canvas canvas) { int y = getMonthHeaderSize() - (MONTH_DAY_LABEL_TEXT_SIZE / 2); int dayWidthHalf = (mWidth - mEdgePadding * 2) / (mNumDays * 2); for (int i = 0; i < mNumDays; i++) { int x = (2 * i + 1) * dayWidthHalf + mEdgePadding; int calendarDay = (i + mWeekStart) % mNumDays; mDayLabelCalendar.set(Calendar.DAY_OF_WEEK, calendarDay); Locale locale = Locale.getDefault(); String localWeekDisplayName = mDayLabelCalendar.getDisplayName(Calendar.DAY_OF_WEEK, Calendar.SHORT, locale);/*from ww w .j a v a 2 s . c o m*/ String weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); if (locale.equals(Locale.CHINA) || locale.equals(Locale.CHINESE) || locale.equals(Locale.SIMPLIFIED_CHINESE) || locale.equals(Locale.TRADITIONAL_CHINESE)) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 1, len); } if (locale.getLanguage().equals("he") || locale.getLanguage().equals("iw")) { if (mDayLabelCalendar.get(Calendar.DAY_OF_WEEK) != Calendar.SATURDAY) { int len = localWeekDisplayName.length(); weekString = localWeekDisplayName.substring(len - 2, len - 1); } else { // I know this is duplication, but it makes the code easier to grok by // having all hebrew code in the same block weekString = localWeekDisplayName.toUpperCase(locale).substring(0, 1); } } canvas.drawText(weekString, x, y, mMonthDayLabelPaint); } }