List of usage examples for java.util Calendar THURSDAY
int THURSDAY
To view the source code for java.util Calendar THURSDAY.
Click Source Link
From source file:com.feilong.core.date.DateExtensionUtilTemp.java
/** * TestCalendarUtilTest./*from w w w. j av a 2 s. com*/ */ @Test public void testCalendarUtilTest() { List<String> weekDateStringList = getWeekDateStringList(Calendar.THURSDAY, COMMON_DATE_AND_TIME_WITH_MILLISECOND); LOGGER.debug(JsonUtil.format(weekDateStringList)); }
From source file:com.clustercontrol.jobmanagement.factory.JobPlanSchedule.java
/** * ????Cron??/*from w w w . ja v a 2s. c om*/ * * @param cron */ private void createPlan(String cron) { /* * cron * */ // * 0 15 * * ? * 1500 // * 0 23 ? * 1 * 2300 // * */10 * * * ? * 10?? String[] planSplit = cron.split(" "); String aster = "*"; String question = "?"; String slash = "/"; if (!aster.equals(planSplit[0])) { secondType = 0; second = Integer.parseInt(planSplit[0]); } if (!aster.equals(planSplit[1])) { String[] slashSplit = planSplit[1].split(slash); int num = 0; for (String str : slashSplit) { m_log.trace("slashSplit[ " + num + " ] =" + str); num++; } //p?q???? if (slashSplit.length == 2) { minuteType = 3; minute = Integer.parseInt(slashSplit[0]); fromMinutes = Integer.parseInt(slashSplit[0]); everyMinutes = Integer.parseInt(slashSplit[1]); } else { minuteType = 0; minute = Integer.parseInt(planSplit[1]); m_log.debug("minuteType=" + minuteType); m_log.debug("minute=" + minute); } } if (!aster.equals(planSplit[2])) { hourType = 0; hour = Integer.parseInt(planSplit[2]); } if (question.equals(planSplit[3])) { dayType = 2; } else if (!aster.equals(planSplit[3])) { dayType = 0; day = Integer.parseInt(planSplit[3]); } if (!aster.equals(planSplit[4])) { monthType = 0; month = Integer.parseInt(planSplit[4]); } if (question.equals(planSplit[5])) { weekType = 2; } else if (!aster.equals(planSplit[5])) { weekType = 0; week = Integer.parseInt(planSplit[5]); } switch (week) { case 1: weekCalendar = Calendar.SUNDAY; break; case 2: weekCalendar = Calendar.MONDAY; break; case 3: weekCalendar = Calendar.TUESDAY; break; case 4: weekCalendar = Calendar.WEDNESDAY; break; case 5: weekCalendar = Calendar.THURSDAY; break; case 6: weekCalendar = Calendar.FRIDAY; break; case 7: weekCalendar = Calendar.SATURDAY; break; default: weekCalendar = Calendar.SUNDAY; } // weekType?0?????????? // ??????????*????0?? if (weekType == 0 && isFireDayOfWeek() == false) { nextFireDay(); if (hourType == 1) { hour = 0; } } }
From source file:org.activequant.util.charting.IntradayMarketTimeline.java
/** * Translates a millisecond (as defined by java.util.Date) into an index * along this timeline./*from w w w . j a v a2s .c om*/ * * @param target - the milliseconds of a date to convert * * @return A timeline value. */ public long toTimelineValue(long currentDayMillis) { // //find out the day of the week the current day is //SUNDAY = 1,...SATURDAY = 7 Calendar currentDay = Calendar.getInstance(TimeZone.getTimeZone("GMT")); currentDay.setTimeInMillis(currentDayMillis); //a list of the days from the current date until last thursday 00:00 //which includes thursday itself from (00:00,23:59) ArrayList<Integer> daysFromThursday = new ArrayList<Integer>(); Calendar lastThursday = Calendar.getInstance(TimeZone.getTimeZone("GMT")); lastThursday.setTimeInMillis(currentDayMillis); //move backwards in time until you hit a wednesday while (lastThursday.get(Calendar.DAY_OF_WEEK) != Calendar.THURSDAY) { //add this day to the list daysFromThursday.add(new Integer(lastThursday.get(Calendar.DAY_OF_WEEK))); // //move back one more day lastThursday.add(Calendar.DATE, -1); } // //add thursday to the list daysFromThursday.add(new Integer(Calendar.THURSDAY)); //adjust Calendar to the beginning of last thursday lastThursday.set(Calendar.MILLISECOND, 0); lastThursday.set(Calendar.SECOND, 0); lastThursday.set(Calendar.MINUTE, 0); lastThursday.set(Calendar.HOUR_OF_DAY, 0); //get the milliseconds for the beginning of last Thursday long lastThursdayMillis = lastThursday.getTimeInMillis(); //because Jan 1, 1970 was a Thursday, lastThursdayMillis //gives an even # of weeks from Jan 1, 1970 until lastThursdayMillis. //so subtract the (down time per week * the //number of weeks) since Jan 1, 1970 //the number of weeks since Jan 1, 1970 int numberOfWeeks = (int) Math.round((new Long(lastThursdayMillis / MILLIS_PER_WEEK)).doubleValue()); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); TimeZone.setDefault(TimeZone.getDefault()); //get the timeline value for the number of millis since //Jan 1, 1970 to last thursday, by multiplying the number of weeks //since Jan 1, 1970 by the amount of active milliseconds per week long timelineValue = numberOfWeeks * this.activeTimePerWeek; // //add the amount of active millseconds for the current day //of the given time long millisOfCurrentDay = currentDay.get(Calendar.HOUR_OF_DAY) * 3600000 + currentDay.get(Calendar.MINUTE) * 60000 + currentDay.get(Calendar.SECOND) * 1000 + currentDay.get(Calendar.MILLISECOND); long startOfCurrentDay = this.getStartTime(currentDay.get(Calendar.DAY_OF_WEEK)); long endOfCurrentDay = this.getEndTime(currentDay.get(Calendar.DAY_OF_WEEK)); if (millisOfCurrentDay >= startOfCurrentDay && millisOfCurrentDay <= endOfCurrentDay) { timelineValue += millisOfCurrentDay - startOfCurrentDay; } //get the size of the list int listSize = daysFromThursday.size(); //add the active time since last thursday, skipping the first day since //we already took care of that for (int i = 1; i < listSize; i++) { int day = ((Integer) daysFromThursday.get(i)).intValue(); timelineValue += this.getActiveTimePerDay(day); } return timelineValue; }
From source file:org.kuali.kfs.module.endow.document.service.impl.FrequencyDatesServiceImpl.java
/** * Method to calculate the next processing week date based on the frequency type * adds the appropriate number of days to the current date * @param dayOfWeek//from w w w.j a v a 2 s .co m * @return next processing date */ protected Calendar calculateNextWeeklyDate(String dayOfWeekFromFrequencyCode, Date currentDate) { Calendar calendar = Calendar.getInstance(); calendar.setTime(currentDate); int daysToAdd = 0; int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); // today's day of the week int maximumDaysInWeek = calendar.getActualMaximum(Calendar.DAY_OF_WEEK); if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.MONDAY)) { if (dayOfWeek < Calendar.MONDAY) daysToAdd = Calendar.MONDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.MONDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.TUESDAY)) { if (dayOfWeek < Calendar.TUESDAY) daysToAdd = Calendar.TUESDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.TUESDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.WEDNESDAY)) { if (dayOfWeek < Calendar.WEDNESDAY) daysToAdd = Calendar.WEDNESDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.WEDNESDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.THURSDAY)) { if (dayOfWeek < Calendar.THURSDAY) daysToAdd = Calendar.THURSDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.THURSDAY; } else if (dayOfWeekFromFrequencyCode.equalsIgnoreCase(EndowConstants.FrequencyWeekDays.FRIDAY)) { if (dayOfWeek < Calendar.FRIDAY) daysToAdd = Calendar.FRIDAY - dayOfWeek; else daysToAdd = maximumDaysInWeek - dayOfWeek + Calendar.FRIDAY; } calendar.add(Calendar.DAY_OF_MONTH, daysToAdd); return calendar; }
From source file:com.pressurelabs.flowopensource.TheHubActivity.java
private void generateDrawerGreeting(NavigationView view) { View header = view.getHeaderView(0); TextView greeting = (TextView) header.findViewById(R.id.ndrawer_date_greeting); String[] array = this.getResources().getStringArray(R.array.drawer_greeting); switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) { case Calendar.MONDAY: greeting.setText(array[0]);// w w w .j a v a 2 s. co m break; case Calendar.TUESDAY: greeting.setText(array[1]); break; case Calendar.WEDNESDAY: greeting.setText(array[2]); break; case Calendar.THURSDAY: greeting.setText(array[3]); break; case Calendar.FRIDAY: greeting.setText(array[4]); break; case Calendar.SATURDAY: greeting.setText(array[5]); break; case Calendar.SUNDAY: greeting.setText(array[6]); break; default: greeting.setText(array[7]); break; } }
From source file:com.eryansky.common.utils.SysUtils.java
public static String getNowDateStr() { String result = dateFormat(getNowDate(), CHS_DATEFORMAT); Calendar c = Calendar.getInstance(); for (int i = 0; i < 8; i++) { c.add(Calendar.DAY_OF_MONTH, 1); @SuppressWarnings("unused") int e = c.get(Calendar.DAY_OF_WEEK); }//from ww w. ja v a 2s . c o m result += " "; switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: return result + ""; case Calendar.MONDAY: return result + ""; case Calendar.TUESDAY: return result + ""; case Calendar.WEDNESDAY: return result + ""; case Calendar.THURSDAY: return result + ""; case Calendar.FRIDAY: return result + ""; case Calendar.SATURDAY: return result + ""; default: return result; } }
From source file:com.mb.framework.util.DateTimeUtil.java
/** * This method is used for getting day of week short description * // w w w . j a v a 2s . com * @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:DateUtils.java
public static final String getDayString(int day) { switch (day) { case Calendar.SUNDAY: return "SUNDAY"; case Calendar.MONDAY: return "MONDAY"; case Calendar.TUESDAY: return "TUESDAY"; case Calendar.WEDNESDAY: return "WEDNESDAY"; case Calendar.THURSDAY: return "THURSDAY"; case Calendar.FRIDAY: return "FRIDAY"; case Calendar.SATURDAY: return "SATURDAY"; }//w ww. j ava2 s . c om return ""; }
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();/*from w ww .j a va 2s . com*/ } 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:de.tor.tribes.ui.components.DatePicker.java
/** * remaps the days of week of gregorian Calendar to internal values *///from www . j ava2 s . 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 } }