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:com.feilong.commons.core.date.DateUtil.java
/** * date (<b></b>) <code>00:00:00.000</code> <br> * ?:,,?<br>//from w w w . j av a2 s . c o m * ?:,? * * <pre> * 2012-10-11 17:10:30.701(), * return 2012-10-07 00:00:00.000 * * * getFirstDateOfThisWeek(2014-01-01 05:00:00) * return 2013-12-29 00:00:00.000 * </pre> * * @param date * the date * @return date <code>00:00:00.000</code> * @see #toCalendar(Date) * @see Calendar#set(int, int) * @see #dayBegin(Calendar) * @see Calendar#getTime() * @since 1.0 */ public static final Date getFirstDateOfThisWeek(Date date) { Calendar calendar = toCalendar(date); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); dayBegin(calendar); return calendar.getTime(); }
From source file:in.suraj.timetableswipe.BTechFragment.java
private void init() { rgroup = (RadioGroup) rootView.findViewById(R.id.rbgrp); rbMon = (RadioButton) rootView.findViewById(R.id.rbMon); rbTue = (RadioButton) rootView.findViewById(R.id.rbTue); rbWed = (RadioButton) rootView.findViewById(R.id.rbWed); rbThur = (RadioButton) rootView.findViewById(R.id.rbThur); rbFri = (RadioButton) rootView.findViewById(R.id.rbFri); tvLect1Name = (TextView) rootView.findViewById(R.id.tvLect1Name); tvLect1Prof = (TextView) rootView.findViewById(R.id.tvLect1Prof); tvLect2Name = (TextView) rootView.findViewById(R.id.tvLect2Name); tvLect2Prof = (TextView) rootView.findViewById(R.id.tvLect2Prof); tvLect3Name = (TextView) rootView.findViewById(R.id.tvLect3Name); tvLect3Prof = (TextView) rootView.findViewById(R.id.tvLect3Prof); tvLect4Name = (TextView) rootView.findViewById(R.id.tvLect4Name); tvLect4Prof = (TextView) rootView.findViewById(R.id.tvLect4Prof); tvLect5Name = (TextView) rootView.findViewById(R.id.tvLect5Name); tvLect5Prof = (TextView) rootView.findViewById(R.id.tvLect5Prof); Calendar c = Calendar.getInstance(); int dayOfWeek = c.get(Calendar.DAY_OF_WEEK); if (Calendar.MONDAY == dayOfWeek) { setUpMonday();/* www . j av a2 s . c om*/ } else if (Calendar.TUESDAY == dayOfWeek) { setUpTuesday(); } else if (Calendar.WEDNESDAY == dayOfWeek) { setUpWednesday(); } else if (Calendar.THURSDAY == dayOfWeek) { setUpThursday(); } else if (Calendar.FRIDAY == dayOfWeek) { setUpFriday(); } else if (Calendar.SATURDAY == dayOfWeek) { tvLect1Name.setText("Saturday :)"); tvLect1Name.setTextColor(Color.RED); } else if (Calendar.SUNDAY == dayOfWeek) { tvLect1Name.setText("Sunday :)"); tvLect1Name.setTextColor(Color.RED); } }
From source file:org.b3log.symphony.processor.ActivityProcessor.java
/** * Shows 1A0001./*from w ww . j ava 2s. c o m*/ * * @param context the specified context * @param request the specified request * @param response the specified response * @throws Exception exception */ @RequestProcessing(value = "/activity/1A0001", method = HTTPRequestMethod.GET) @Before(adviceClass = { StopwatchStartAdvice.class, LoginCheck.class }) @After(adviceClass = { CSRFToken.class, StopwatchEndAdvice.class }) public void show1A0001(final HTTPRequestContext context, final HttpServletRequest request, final HttpServletResponse response) throws Exception { request.setAttribute(Keys.TEMAPLTE_DIR_NAME, Symphonys.get("skinDirName")); final AbstractFreeMarkerRenderer renderer = new SkinRenderer(); context.setRenderer(renderer); renderer.setTemplateName("/activity/1A0001.ftl"); final Map<String, Object> dataModel = renderer.getDataModel(); final JSONObject currentUser = (JSONObject) request.getAttribute(User.USER); final String userId = currentUser.optString(Keys.OBJECT_ID); final boolean closed = Symphonys.getBoolean("activity1A0001Closed"); dataModel.put(Common.CLOSED, closed); final Calendar calendar = Calendar.getInstance(); final int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); final boolean closed1A0001 = dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY; dataModel.put(Common.CLOSED_1A0001, closed1A0001); final int hour = calendar.get(Calendar.HOUR_OF_DAY); final int minute = calendar.get(Calendar.MINUTE); final boolean end = hour > 14 || (hour == 14 && minute > 55); dataModel.put(Common.END, end); final boolean collected = activityQueryService.isCollected1A0001Today(userId); dataModel.put(Common.COLLECTED, collected); final boolean participated = activityQueryService.is1A0001Today(userId); dataModel.put(Common.PARTICIPATED, participated); while (true) { if (closed) { dataModel.put(Keys.MSG, langPropsService.get("activityClosedLabel")); break; } if (closed1A0001) { dataModel.put(Keys.MSG, langPropsService.get("activity1A0001CloseLabel")); break; } if (collected) { dataModel.put(Keys.MSG, langPropsService.get("activityParticipatedLabel")); break; } if (participated) { dataModel.put(Common.HOUR, hour); final List<JSONObject> records = pointtransferQueryService.getLatestPointtransfers(userId, Pointtransfer.TRANSFER_TYPE_C_ACTIVITY_1A0001, 1); final JSONObject pointtransfer = records.get(0); final String data = pointtransfer.optString(Pointtransfer.DATA_ID); final String smallOrLarge = data.split("-")[1]; final int sum = pointtransfer.optInt(Pointtransfer.SUM); String msg = langPropsService.get("activity1A0001BetedLabel"); final String small = langPropsService.get("activity1A0001BetSmallLabel"); final String large = langPropsService.get("activity1A0001BetLargeLabel"); msg = msg.replace("{smallOrLarge}", StringUtils.equals(smallOrLarge, "0") ? small : large); msg = msg.replace("{point}", String.valueOf(sum)); dataModel.put(Keys.MSG, msg); break; } if (end) { dataModel.put(Keys.MSG, langPropsService.get("activityEndLabel")); break; } break; } filler.fillHeaderAndFooter(request, response, dataModel); filler.fillRandomArticles(dataModel); filler.fillHotArticles(dataModel); filler.fillSideTags(dataModel); filler.fillLatestCmts(dataModel); }
From source file:org.faster.util.DateTimes.java
/** * ?/* ww w. j av a2 s . com*/ * * @param date * * @return ? */ public static boolean isWeekend(Date date) { if (date == null) { throw new IllegalArgumentException("date must not be null!"); } Calendar cal = Calendar.getInstance(); cal.setTime(date); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); return dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY; }
From source file:org.davidmendoza.esu.service.impl.InicioServiceImpl.java
private String obtieneDia(int dia) { switch (dia) { case Calendar.SUNDAY: return "domingo"; case Calendar.MONDAY: return "lunes"; case Calendar.TUESDAY: return "martes"; case Calendar.WEDNESDAY: return "miercoles"; case Calendar.THURSDAY: return "jueves"; case Calendar.FRIDAY: return "viernes"; default:/*from w w w.jav a 2s . co m*/ return "sabado"; } }
From source file:com.discovery.darchrow.date.DateUtil.java
/** * date <span style="color:red"> ()</span> <code>00:00:00.000</code> . * <p>//from w w w .ja va 2 s . c o m * ?:,<span style="color:red">,?</span><br> * ?:,? * </p> * * <pre> * 2012-10-11 17:10:30.701(), * return 2012-10-07 00:00:00.000 * * * getFirstDateOfThisWeek(2014-01-01 05:00:00) * return 2013-12-29 00:00:00.000 * </pre> * * @param date * the date * @return date <code>00:00:00.000</code> * @see #toCalendar(Date) * @see Calendar#set(int, int) * @see CalendarUtil#resetDayBegin(Calendar) * @see Calendar#getTime() */ public static Date getFirstDateOfThisWeek(Date date) { Calendar calendar = toCalendar(date); calendar.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); CalendarUtil.resetDayBegin(calendar); return CalendarUtil.toDate(calendar); }
From source file:de.tor.tribes.ui.components.DatePicker.java
/** * remaps the days of week of gregorian Calendar to internal values */// ww w.j a va2s .c o m private int mapDayOfWeek(int cal) { switch (cal) { case Calendar.MONDAY: return 1; case Calendar.TUESDAY: return 2; case Calendar.WEDNESDAY: return 3; case Calendar.THURSDAY: return 4; case Calendar.FRIDAY: return 5; case Calendar.SATURDAY: return 6; case Calendar.SUNDAY: return 7; default: return 1; //should never happen } }
From source file:ru.VirtaMarketAnalyzer.main.Wizard.java
public static void collectToJsonTradeAtCities(final String realm) throws IOException { final String baseDir = Utils.getDir() + by_trade_at_cities + File.separator + realm + File.separator; final String serviceBaseDir = Utils.getDir() + by_service + File.separator + realm + File.separator; final File baseDirFile = new File(baseDir); if (baseDirFile.exists()) { logger.info("? {}", baseDirFile.getAbsolutePath()); FileUtils.deleteDirectory(baseDirFile); }//from w ww . j a v a2s . co m final File serviceBaseDirFile = new File(serviceBaseDir); if (serviceBaseDirFile.exists()) { logger.info("? {}", serviceBaseDirFile.getAbsolutePath()); FileUtils.deleteDirectory(serviceBaseDirFile); } //? final List<Country> countries = CityInitParser .getCountries(host + realm + "/main/common/main_page/game_info/world/"); Utils.writeToGson(baseDir + "countries.json", countries); final List<Country> countries_en = CityInitParser .getCountries(host_en + realm + "/main/common/main_page/game_info/world/"); Utils.writeToGson(baseDir + "countries_en.json", countries_en); // final List<Region> regions = CityInitParser.getRegions(host + realm + "/main/geo/regionlist/", countries); Utils.writeToGson(baseDir + "regions.json", regions); final List<Region> regions_en = CityInitParser.getRegions(host_en + realm + "/main/geo/regionlist/", countries); Utils.writeToGson(baseDir + "regions_en.json", regions_en); // ? final List<City> cities = CityListParser.fillWealthIndex(host + realm + "/main/geo/citylist/", regions); Utils.writeToGson(baseDir + "cities.json", cities); final List<City> cities_en = CityListParser.fillWealthIndex(host_en + realm + "/main/geo/citylist/", regions); Utils.writeToGson(baseDir + "cities_en.json", cities_en); logger.info("cities.size() = {}, realm = {}", cities.size(), realm); logger.info(" ?? ? "); final List<Product> products = ProductInitParser.getTradingProducts(host, realm); Utils.writeToGson(baseDir + "products.json", products); final List<Product> products_en = ProductInitParser.getTradingProducts(host_en, realm); Utils.writeToGson(baseDir + "products_en.json", products_en); logger.info("products.size() = {}, realm = {}", products.size(), realm); saveProductImg(products); logger.info(" ?? ? ??"); final List<UnitType> unitTypes = ServiceInitParser.getServiceUnitTypes(host, realm); Utils.writeToGson(serviceBaseDir + "service_unit_types.json", unitTypes); final List<UnitType> unitTypes_en = ServiceInitParser.getServiceUnitTypes(host_en, realm); Utils.writeToGson(serviceBaseDir + "service_unit_types_en.json", unitTypes_en); logger.info("service_unit_types.size() = {}, realm = {}", unitTypes.size(), realm); saveUnitTypeImg(unitTypes); final Calendar today = Calendar.getInstance(); if ("olga".equalsIgnoreCase(realm) && (today.get(Calendar.DAY_OF_WEEK) == Calendar.WEDNESDAY || today.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY)) { } else if ("anna".equalsIgnoreCase(realm) && today.get(Calendar.DAY_OF_WEEK) == Calendar.TUESDAY) { } else if ("mary".equalsIgnoreCase(realm) && today.get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY) { } else if ("lien".equalsIgnoreCase(realm) && today.get(Calendar.DAY_OF_WEEK) == Calendar.FRIDAY) { } else if ("vera".equalsIgnoreCase(realm) && (today.get(Calendar.DAY_OF_WEEK) == Calendar.THURSDAY || today.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY)) { } else if ("fast".equalsIgnoreCase(realm)) { } else { return; } logger.info( " ?? ? "); final List<ProductCategory> product_categories = ProductInitParser.getProductCategories(products); Utils.writeToGson(baseDir + "product_categories.json", product_categories); final List<ProductCategory> product_categories_en = ProductInitParser.getProductCategories(products_en); Utils.writeToGson(baseDir + "product_categories_en.json", product_categories_en); logger.info(" ?"); final List<Product> materials = ProductInitParser.getProducts(host, realm); final Map<String, List<CountryDutyList>> countriesDutyList = CountryDutyListParser .getAllCountryDutyList(host + realm + "/main/geo/countrydutylist/", countries, materials); for (final Map.Entry<String, List<CountryDutyList>> entry : countriesDutyList.entrySet()) { Utils.writeToGson(baseDir + countrydutylist + File.separator + entry.getKey() + ".json", entry.getValue()); } logger.info("? "); final Map<String, List<TradeAtCity>> stats = CityParser.collectByTradeAtCities(host, realm, cities, products, countriesDutyList, regions); //?? json for (final Map.Entry<String, List<TradeAtCity>> entry : stats.entrySet()) { Utils.writeToGson(baseDir + "tradeAtCity_" + entry.getKey() + ".json", entry.getValue()); } logger.info(" ? "); final DateFormat df = new SimpleDateFormat("dd.MM.yyyy"); Utils.writeToGson(baseDir + "updateDate.json", new UpdateDate(df.format(new Date()))); logger.info("? "); final List<Shop> shops = TopRetailParser.getShopList(realm, stats, products); logger.info( " ?? ? "); final Map<String, List<RetailAnalytics>> retailAnalytics = PrepareAnalitics .getRetailAnalitincsByProducts(shops, stats, products); for (final Map.Entry<String, List<RetailAnalytics>> entry : retailAnalytics.entrySet()) { Utils.writeToGsonZip(baseDir + RetailSalePrediction.RETAIL_ANALYTICS_ + entry.getKey() + ".json", entry.getValue()); } logger.info(" ?? "); for (final UnitType ut : unitTypes) { final List<ServiceAtCity> serviceAtCity = ServiceAtCityParser.get(host, realm, cities, ut, regions); Utils.writeToGson(serviceBaseDir + "serviceAtCity_" + ut.getId() + ".json", serviceAtCity); } for (final UnitType ut : unitTypes_en) { final List<ServiceAtCity> serviceAtCity_en = ServiceAtCityParser.get(host_en, realm, cities_en, ut, regions_en); Utils.writeToGson(serviceBaseDir + "serviceAtCity_" + ut.getId() + "_en.json", serviceAtCity_en); } logger.info(" ? "); Utils.writeToGson(serviceBaseDir + "updateDate.json", new UpdateDate(df.format(new Date()))); // ? // RetailSalePrediction.createPrediction(realm, retailAnalytics, products); }
From source file:com.netflix.simianarmy.basic.BasicCalendar.java
/** * Work day in year./*from ww w . j a v a 2 s.c om*/ * * @param year * the year * @param month * the month * @param day * the day * @return the day of the year adjusted to the closest workday */ private int workDayInYear(int year, int month, int day) { Calendar holiday = now(); holiday.set(Calendar.YEAR, year); holiday.set(Calendar.MONTH, month); holiday.set(Calendar.DAY_OF_MONTH, day); int doy = holiday.get(Calendar.DAY_OF_YEAR); int dow = holiday.get(Calendar.DAY_OF_WEEK); if (dow == Calendar.SATURDAY) { return doy - 1; // FRIDAY } if (dow == Calendar.SUNDAY) { return doy + 1; // MONDAY } return doy; }
From source file:com.oginotihiro.datepicker.DatePickerDialog.java
public void setFirstDayOfWeek(int startOfWeek) { if (startOfWeek < Calendar.SUNDAY || startOfWeek > Calendar.SATURDAY) { throw new IllegalArgumentException("Value must be between Calendar.SUNDAY and " + "Calendar.SATURDAY"); }//from ww w. j a v a 2s .c o m mWeekStart = startOfWeek; if (mDayPickerView != null) { mDayPickerView.onChanged(); } }