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:net.firejack.platform.core.utils.DateUtils.java
/** * Truncates the date to week level/*from www. j a v a2s .c om*/ * @param date - date to be truncated * @return truncated date */ public static Date truncateDateToWeek(Date date) { Calendar cal = new GregorianCalendar(); cal.setTime(DateUtils.truncate(date, Calendar.DAY_OF_MONTH)); while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { cal.add(Calendar.DAY_OF_MONTH, -1); } return cal.getTime(); }
From source file:org.sakaiproject.util.CalendarUtil.java
void initDates() { Calendar calendarSunday = Calendar.getInstance(); Calendar calendarMonday = Calendar.getInstance(); Calendar calendarTuesday = Calendar.getInstance(); Calendar calendarWednesday = Calendar.getInstance(); Calendar calendarThursday = Calendar.getInstance(); Calendar calendarFriday = Calendar.getInstance(); Calendar calendarSaturday = Calendar.getInstance(); calendarSunday.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); calendarMonday.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); calendarTuesday.set(Calendar.DAY_OF_WEEK, Calendar.TUESDAY); calendarWednesday.set(Calendar.DAY_OF_WEEK, Calendar.WEDNESDAY); calendarThursday.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); calendarFriday.set(Calendar.DAY_OF_WEEK, Calendar.FRIDAY); calendarSaturday.set(Calendar.DAY_OF_WEEK, Calendar.SATURDAY); dateSunday = calendarSunday.getTime(); dateMonday = calendarMonday.getTime(); dateTuesday = calendarTuesday.getTime(); dateWednesday = calendarWednesday.getTime(); dateThursday = calendarThursday.getTime(); dateFriday = calendarFriday.getTime(); dateSaturday = calendarSaturday.getTime(); Calendar calendarJanuary = Calendar.getInstance(); Calendar calendarFebruary = Calendar.getInstance(); Calendar calendarMarch = Calendar.getInstance(); Calendar calendarApril = Calendar.getInstance(); Calendar calendarMay = Calendar.getInstance(); Calendar calendarJune = Calendar.getInstance(); Calendar calendarJuly = Calendar.getInstance(); Calendar calendarAugust = Calendar.getInstance(); Calendar calendarSeptember = Calendar.getInstance(); Calendar calendarOctober = Calendar.getInstance(); Calendar calendarNovember = Calendar.getInstance(); Calendar calendarDecember = Calendar.getInstance(); calendarJanuary.set(Calendar.MONTH, Calendar.JANUARY); calendarFebruary.set(Calendar.MONTH, Calendar.FEBRUARY); calendarMarch.set(Calendar.MONTH, Calendar.MARCH); calendarApril.set(Calendar.MONTH, Calendar.APRIL); calendarMay.set(Calendar.MONTH, Calendar.MAY); calendarJune.set(Calendar.MONTH, Calendar.JUNE); calendarJuly.set(Calendar.MONTH, Calendar.JULY); calendarAugust.set(Calendar.MONTH, Calendar.AUGUST); calendarSeptember.set(Calendar.MONTH, Calendar.SEPTEMBER); calendarOctober.set(Calendar.MONTH, Calendar.OCTOBER); calendarNovember.set(Calendar.MONTH, Calendar.NOVEMBER); calendarDecember.set(Calendar.MONTH, Calendar.DECEMBER); dateJanuary = calendarJanuary.getTime(); dateFebruary = calendarFebruary.getTime(); dateMarch = calendarMarch.getTime(); dateApril = calendarApril.getTime(); dateMay = calendarMay.getTime();/*from ww w. ja v a 2 s. c o m*/ dateJune = calendarJune.getTime(); dateJuly = calendarJuly.getTime(); dateAugust = calendarAugust.getTime(); dateSeptember = calendarSeptember.getTime(); dateOctober = calendarOctober.getTime(); dateNovember = calendarNovember.getTime(); dateDecember = calendarDecember.getTime(); }
From source file:net.chaosserver.timelord.swingui.ChartingPanel.java
/** * Creates the dataset to be charted.//from w w w . ja v a2 s . c o m * * @return the dataset to be charted. */ private CategoryDataset createDataset() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Calendar calendar = Calendar.getInstance(); DateUtil.trunc(calendar); calendar.add(Calendar.DATE, -FIRST_DATE); String series1 = "Total Hours"; for (int i = 0; i < FIRST_DATE; i++) { if (Calendar.SATURDAY != calendar.get(Calendar.DAY_OF_WEEK) && Calendar.SUNDAY != calendar.get(Calendar.DAY_OF_WEEK)) { TimelordDayView timelordDayView = new TimelordDayView(timelordData, calendar.getTime()); double totalTime = timelordDayView.getTotalTimeToday(false); if (log.isTraceEnabled()) { log.trace("Creating Value of totalTime [" + totalTime + "], series1 = " + series1 + " category [" + calendar.getTime() + "]"); } dataset.addValue(totalTime, series1, calendar.getTime()); timelordDayView.dispose(); } calendar.add(Calendar.DATE, 1); } return dataset; }
From source file:com.lugia.timetable.TimeTableFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log.d(TAG, "onCreateView()"); mColors = Utils.getForegroundColorArrays(getActivity()); mBackgrounds = Utils.getBackgroundDrawableResourceIds(); View view = inflater.inflate(R.layout.fragment_time_table, null); mTimeTable = (TimeTableLayout) view.findViewById(R.id.time_table); SubjectList subjects = SubjectList.getInstance(getActivity()); for (Subject subject : subjects) { int colorIndex = subject.getColor(); for (Schedule schedule : subject.getSchedules()) { View child = inflater.inflate(R.layout.item_time_table_schedule, mTimeTable, false); child.setBackgroundResource(mBackgrounds[colorIndex]); child.setTag(subject.getSubjectCode()); TextView subjectCodeTextView = (TextView) child.findViewById(R.id.text_subject_code); TextView subjectDescriptionTextView = (TextView) child.findViewById(R.id.text_subject_description); TextView sectionTextView = (TextView) child.findViewById(R.id.text_section); TextView roomTextView = (TextView) child.findViewById(R.id.text_room); subjectCodeTextView.setText(subject.getSubjectCode()); subjectDescriptionTextView.setText(subject.getSubjectDescription()); sectionTextView.setText(subject.getSection(schedule.getSection())); roomTextView.setText(schedule.getRoom()); subjectCodeTextView.setTextColor(mColors[colorIndex]); subjectDescriptionTextView.setTextColor(mColors[colorIndex]); sectionTextView.setTextColor(mColors[colorIndex]); roomTextView.setTextColor(mColors[colorIndex]); mTimeTable.addView(child, schedule.getDay(), schedule.getTime(), schedule.getLength()); }// ww w . j a v a 2 s .com } mTimeTable.setOnDayChangedListener((MasterActivity) getActivity()); mTimeTable.setOnItemClickListener(TimeTableFragment.this); // set the current day of this view initially according to real world day switch (Calendar.getInstance().get(Calendar.DAY_OF_WEEK)) { case Calendar.SATURDAY: case Calendar.SUNDAY: mTimeTable.setCurrentDay(TimeTableLayout.MONDAY); break; default: mTimeTable.setCurrentDay(Calendar.getInstance().get(Calendar.DAY_OF_WEEK) - 1); // scroll to current time position for user convenient mTimeTable.scrollToCurrentTime(); break; } return view; }
From source file:util.MyUtils.java
public static String getWeekDay(String dob) { // sun - 1, mon (2), tue(3), wed(4), thu (5), fri(6) int day = new Integer(dob.substring(8, dob.length())).intValue(); Calendar cal = Calendar.getInstance(); cal.set(new Integer(getYear(dob)).intValue(), new Integer(getMonthNum(dob)).intValue(), day); int weekDay = cal.get(Calendar.DAY_OF_WEEK); switch (weekDay) { 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"; }//from w w w . j a v a 2 s .c o m return ""; }
From source file:com.clican.pluto.common.calendar.BusinessCalendar.java
/** * Initial method /* w w w. j a va 2 s . com*/ */ public void init() { days = new BusinessDay[8]; days[Calendar.SUNDAY] = parseDay(sunday); days[Calendar.MONDAY] = parseDay(monday); days[Calendar.TUESDAY] = parseDay(tuesday); days[Calendar.WEDNESDAY] = parseDay(wednesday); days[Calendar.THURSDAY] = parseDay(thursday); days[Calendar.FRIDAY] = parseDay(friday); days[Calendar.SATURDAY] = parseDay(saturday); holidays = new Holiday[holidayList.size()]; for (int i = 0; i < holidayList.size(); i++) { holidays[i] = parseHoliday(holidayList.get(i)); } }
From source file:net.granoeste.commons.util.DateUtils.java
/** * ?????// w w w .j a v a 2 s . c om * * @param cal * @param amount ex) last month : -1. the current month : 0. the next month : 1 */ public static void shiftDateOnMondayOfAWeekAtTheBeginningOfTheMonth(final Calendar cal, final int amount) { cal.set(Calendar.DATE, 1); cal.add(Calendar.MONTH, amount); if (cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) { cal.add(Calendar.DATE, -6); } else { cal.add(Calendar.DATE, -cal.get(Calendar.DAY_OF_WEEK) + 2); } }
From source file:ru.codeinside.calendar.BusinessCalendarDueDateCalculator.java
private boolean isWeekEnd(Calendar calendar) { int day = calendar.get(Calendar.DAY_OF_WEEK); return day == Calendar.SUNDAY || day == Calendar.SATURDAY; }
From source file:verdandi.model.WeekSelectorModel.java
public String getCurrentMondaySundayRange() { return getDateRep(Calendar.MONDAY) + " - " + getDateRep(Calendar.SUNDAY); }
From source file:com.linuxbox.enkive.statistics.gathering.past.PastGatherer.java
protected void setEndDate(int grain) { Calendar end = Calendar.getInstance(); end.set(Calendar.MILLISECOND, 0); end.set(Calendar.SECOND, 0);//from w ww . j av a 2 s. c o m end.set(Calendar.MINUTE, 0); if (grain == CONSOLIDATION_HOUR) { end.add(Calendar.HOUR_OF_DAY, -hrKeepTime); } else if (grain == CONSOLIDATION_DAY) { end.set(Calendar.HOUR_OF_DAY, 0); end.add(Calendar.DATE, -dayKeepTime); } else if (grain == CONSOLIDATION_WEEK) { end.set(Calendar.HOUR_OF_DAY, 0); while (end.get(Calendar.DAY_OF_WEEK) != Calendar.SUNDAY) { end.add(Calendar.DATE, -1); } end.add(Calendar.WEEK_OF_YEAR, -weekKeepTime); } else if (grain == CONSOLIDATION_MONTH) { end.set(Calendar.HOUR_OF_DAY, 0); end.set(Calendar.DAY_OF_MONTH, 1); end.add(Calendar.MONTH, -monthKeepTime); } this.endDate = end.getTime(); }