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.xandy.calendar.month.MonthByWeekFragment.java
@Override protected void setUpHeader() { if (mIsMiniMonth) { super.setUpHeader(); return;//w w w . j a va 2 s. c o m } mDayLabels = new String[7]; for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) { mDayLabels[i - Calendar.SUNDAY] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM) .toUpperCase(); } }
From source file:de.micromata.genome.util.types.DateUtils.java
/** * Ensure workday.//from w w w . j av a2 s . co m * * @param cal the cal */ protected static void ensureWorkday(Calendar cal) { int dow = cal.get(Calendar.DAY_OF_WEEK); while (dow == Calendar.SATURDAY || dow == Calendar.SUNDAY) { cal.add(Calendar.DAY_OF_YEAR, 1); dow = cal.get(Calendar.DAY_OF_WEEK); } }
From source file:de.austinpadernale.holidays.Holiday.java
public Calendar shift(Calendar cal, String country, String region) { int dow = cal.get(Calendar.DAY_OF_WEEK); if (dow != Calendar.SATURDAY && dow != Calendar.SUNDAY) { return cal; }//from www.j a va 2 s.co m HolidayShift hs = getShift(country, region); if (hs == null || hs.getShiftType() == ShiftType.None) { return cal; } int step; switch (hs.getShiftType()) { case Back: step = -1; break; case Forth: step = 1; break; case BackAndForth: step = dow == Calendar.SATURDAY ? -1 : 1; break; default: return cal; } while (dow == Calendar.SATURDAY || dow == Calendar.SUNDAY) { cal.add(Calendar.DATE, step); dow = cal.get(Calendar.DAY_OF_WEEK); } return cal; }
From source file:com.android.calendar.month.MonthByWeekFragment.java
@Override protected void setUpHeader() { if (mIsMiniMonth) { super.setUpHeader(); return;/*from w w w . j a va 2 s .c om*/ } mDayLabels = new String[7]; for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) { mDayLabels[i - Calendar.SUNDAY] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_LONG).toUpperCase(); } }
From source file:org.kuali.coeus.common.committee.impl.bo.CommitteeScheduleBase.java
/** * This UI support method to find day Of week from BO's persistent field scheduledDate. * @return/* w ww . j a va 2 s . com*/ */ public String getDayOfWeek() { Calendar cl = new GregorianCalendar(); cl.setTime(scheduledDate); DayOfWeek dayOfWeek = null; switch (cl.get(Calendar.DAY_OF_WEEK)) { case Calendar.SUNDAY: dayOfWeek = DayOfWeek.Sunday; break; case Calendar.MONDAY: dayOfWeek = DayOfWeek.Monday; break; case Calendar.TUESDAY: dayOfWeek = DayOfWeek.Tuesday; break; case Calendar.WEDNESDAY: dayOfWeek = DayOfWeek.Wednesday; break; case Calendar.THURSDAY: dayOfWeek = DayOfWeek.Thursday; break; case Calendar.FRIDAY: dayOfWeek = DayOfWeek.Friday; break; case Calendar.SATURDAY: dayOfWeek = DayOfWeek.Saturday; break; } return dayOfWeek.name().toUpperCase(); }
From source file:com.easysoft.build.manager.BuildConfigInfoService.java
private static String makeWeekBugDeployPackName(RepInfo ri) throws Exception { Date curDate = DateUtil.toDate(ri.getCreateDate(), "yyyyMMdd");// ? String dateVersion = (ri.getVersionPattern() == null ? "" : new SimpleDateFormat(ri.getVersionPattern()).format(curDate));// ?? // ????//from ww w . j a va 2s. co m Calendar cal = Calendar.getInstance(); int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); // ??02-08 String smallVersion = (dayOfWeek == Calendar.SUNDAY) ? "08" // 1 : new DecimalFormat("00").format(dayOfWeek);// 2-7 String patchName = ri.getBand() + "." + ri.getVersionNo() + ri.getSpNo() + "." + dateVersion + smallVersion + "." + ri.getVersionSuffix(); return patchName; }
From source file:CalendarUtils.java
/** * This constructs an Iterator that will start and stop over a date * range based on the focused date and the range style. For instance, * passing Thursday, July 4, 2002 and a RANGE_MONTH_SUNDAY will return * an Iterator that starts with Sunday, June 30, 2002 and ends with * Saturday, August 3, 2002./* w ww . j a v a2s. com*/ */ public static Iterator getCalendarIterator(Calendar focus, int rangeStyle) { Calendar start = null; Calendar end = null; int startCutoff = Calendar.SUNDAY; int endCutoff = Calendar.SATURDAY; switch (rangeStyle) { case RANGE_MONTH_SUNDAY: case RANGE_MONTH_MONDAY: //Set start to the first of the month start = trunc(focus, Calendar.MONTH); //Set end to the last of the month end = (Calendar) start.clone(); end.add(Calendar.MONTH, 1); end.add(Calendar.DATE, -1); //Loop start back to the previous sunday or monday if (rangeStyle == RANGE_MONTH_MONDAY) { startCutoff = Calendar.MONDAY; endCutoff = Calendar.SUNDAY; } break; case RANGE_WEEK_SUNDAY: case RANGE_WEEK_MONDAY: case RANGE_WEEK_RELATIVE: case RANGE_WEEK_CENTER: //Set start and end to the current date start = trunc(focus, Calendar.DATE); end = trunc(focus, Calendar.DATE); switch (rangeStyle) { case RANGE_WEEK_SUNDAY: //already set by default break; case RANGE_WEEK_MONDAY: startCutoff = Calendar.MONDAY; endCutoff = Calendar.SUNDAY; break; case RANGE_WEEK_RELATIVE: startCutoff = focus.get(Calendar.DAY_OF_WEEK); endCutoff = startCutoff - 1; break; case RANGE_WEEK_CENTER: startCutoff = focus.get(Calendar.DAY_OF_WEEK) - 3; endCutoff = focus.get(Calendar.DAY_OF_WEEK) + 3; break; } break; default: throw new RuntimeException("The range style " + rangeStyle + " is not valid."); } if (startCutoff < Calendar.SUNDAY) { startCutoff += 7; } if (endCutoff > Calendar.SATURDAY) { endCutoff -= 7; } while (start.get(Calendar.DAY_OF_WEEK) != startCutoff) { start.add(Calendar.DATE, -1); } while (end.get(Calendar.DAY_OF_WEEK) != endCutoff) { end.add(Calendar.DATE, 1); } final Calendar startFinal = start; final Calendar endFinal = end; Iterator it = new Iterator() { Calendar spot = null; { spot = startFinal; spot.add(Calendar.DATE, -1); } public boolean hasNext() { return spot.before(endFinal); } public Object next() { if (spot.equals(endFinal)) { throw new NoSuchElementException(); } spot.add(Calendar.DATE, 1); return spot.clone(); } public void remove() { throw new UnsupportedOperationException(); } }; return it; }
From source file:com.baifendian.swordfish.execserver.parameter.placeholder.TimePlaceholderUtil.java
/** * ? <p>/*from w w w. j a v a2s . c o m*/ */ public static Date getSunday(Date date) { Calendar cal = Calendar.getInstance(); cal.setTime(date); // ? cal.setFirstDayOfWeek(Calendar.MONDAY); cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); return cal.getTime(); }
From source file:org.apache.lens.cube.parse.DateUtil.java
public static CoveringInfo getWeeklyCoveringInfo(Date from, Date to) { int dayDiff = 0; Date tmpFrom = from;/*from w w w . ja v a2 s.c o m*/ while (tmpFrom.before(to)) { tmpFrom = DateUtils.addDays(tmpFrom, 1); dayDiff++; } if (dayDiff < 7) { return new CoveringInfo(0, false); } Calendar cal = Calendar.getInstance(); cal.setTime(from); int fromWeek = cal.get(Calendar.WEEK_OF_YEAR); int fromDay = cal.get(Calendar.DAY_OF_WEEK); int fromYear = cal.get(YEAR); cal.clear(); cal.set(YEAR, fromYear); cal.set(Calendar.WEEK_OF_YEAR, fromWeek); cal.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); int maxDayInWeek = cal.getActualMaximum(Calendar.DAY_OF_WEEK); Date fromWeekStartDate = cal.getTime(); boolean coverable = dayDiff % 7 == 0; if (fromWeekStartDate.before(from)) { // Count from the start of next week dayDiff -= (maxDayInWeek - (fromDay - Calendar.SUNDAY)); coverable = false; } return new CoveringInfo(dayDiff / 7, coverable); }
From source file:edu.ucsb.nceas.metacattest.UploadIPCCDataTest.java
private String generateId() { int version = 1; StringBuffer docid = new StringBuffer(DATAIDPREFIX); docid.append(DOT);/*ww w . jav a2 s . com*/ // Create a calendar to get the date formatted properly String[] ids = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000); SimpleTimeZone pdt = new SimpleTimeZone(-8 * 60 * 60 * 1000, ids[0]); pdt.setStartRule(Calendar.APRIL, 1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); pdt.setEndRule(Calendar.OCTOBER, -1, Calendar.SUNDAY, 2 * 60 * 60 * 1000); Calendar calendar = new GregorianCalendar(pdt); Date trialTime = new Date(); calendar.setTime(trialTime); int time = 0; docid.append(calendar.get(Calendar.YEAR)); time = calendar.get(Calendar.DAY_OF_YEAR); if (time < 10) { docid.append("0"); docid.append("0"); docid.append(time); } else if (time < 100) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.HOUR_OF_DAY); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.MINUTE); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } time = calendar.get(Calendar.SECOND); if (time < 10) { docid.append("0"); docid.append(time); } else { docid.append(time); } //sometimes this number is not unique, so we append a random number int random = (new Double(Math.random() * 100)).intValue(); docid.append(random); docid.append(DOT); docid.append(version); return docid.toString(); }