List of usage examples for java.util Calendar DAY_OF_YEAR
int DAY_OF_YEAR
To view the source code for java.util Calendar DAY_OF_YEAR.
Click Source Link
get
and set
indicating the day number within the current year. From source file:sand.actionhandler.weibo.UdaClient.java
public static String getUpPath() { String pathStr = ""; String currYear = Calendar.getInstance().get(Calendar.YEAR) + ""; String currDay = Calendar.getInstance().get(Calendar.DAY_OF_YEAR) + ""; //BaseJob.// w w w .ja va 2s .c o m pathStr = ActionHandler._context.getRealPath("/") + "erp.upload/" + currYear + "/" + currDay + "/"; logger.info("path str is " + pathStr); File f = new File(pathStr); if (!f.exists()) { f.mkdirs(); } return pathStr; }
From source file:com.zimbra.cs.mailbox.calendar.ZRecur.java
private Date estimateEndTimeByUntilAndHardLimits(ParsedDateTime dtStart) throws ServiceException { boolean forever = false; Calendar hardEnd = dtStart.getCalendarCopy(); Frequency freq = mFreq;/*from ww w . j a v a 2 s. c o m*/ if (freq == null) freq = Frequency.WEEKLY; switch (freq) { case WEEKLY: int weeks = sExpansionLimits.maxWeeks; if (weeks <= 0) forever = true; else hardEnd.add(Calendar.WEEK_OF_YEAR, weeks); break; case MONTHLY: int months = sExpansionLimits.maxMonths; if (months <= 0) forever = true; else hardEnd.add(Calendar.MONTH, months); break; case YEARLY: int years = sExpansionLimits.maxYears; if (years <= 0) forever = true; else hardEnd.add(Calendar.YEAR, years); break; case DAILY: int days = sExpansionLimits.maxDays; if (days <= 0) forever = true; else hardEnd.add(Calendar.DAY_OF_YEAR, days); break; default: int otherFreqYears = Math.max(sExpansionLimits.maxYearsOtherFreqs, 1); hardEnd.add(Calendar.YEAR, otherFreqYears); } Date d; if (forever) d = new Date(MAX_DATE_MILLIS); else d = hardEnd.getTime(); if (mUntil != null) { Date until = mUntil.getDateForRecurUntil(dtStart.getTimeZone()); if (until.before(d)) d = until; } return d; }
From source file:TimeSpan.java
/** * Adds the duration of this time span to the provided {@code Calendar} * instance, moving it forward in time./*from w w w. j av a2 s. co m*/ * * @param c the calendar whose date will be moved forward by the duration of * this time span */ public void addTo(Calendar c) { c.add(Calendar.YEAR, years); c.add(Calendar.MONTH, months); c.add(Calendar.WEEK_OF_YEAR, weeks); c.add(Calendar.DAY_OF_YEAR, days); c.add(Calendar.HOUR_OF_DAY, hours); }
From source file:com.netflix.simianarmy.basic.BasicCalendar.java
/** * Work day in year.// w ww . j a v a 2s .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.msds.km.controller.BespeakController.java
@RequestMapping("/editMember") public ModelAndView editMember(MemberEntity entity, HttpServletRequest request) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); Calendar rightNow = Calendar.getInstance(); rightNow.add(Calendar.DAY_OF_YEAR, -1); Date dt1 = rightNow.getTime(); String reStr = sdf.format(dt1); List<MemberEntity> list = bespeakService.getMemberList(entity); if (null != list && list.size() > 0) { MemberEntity member = list.get(0); member.setIsEdit(true);// w w w . j a v a 2 s. c o m request.setAttribute("member", member); request.setAttribute("now", reStr); } return forword("/km/member/member_edit", null); }
From source file:de.hshannover.f4.trust.irondetectprocedures.MeanDaily.java
/** * Calculates the duration in days from start to end. Example: * 1.1.2011 to 5.1.2011 would return 5./*from w w w. j av a 2s . c o m*/ * @param start * @param end * @return */ private int durationInDays(Calendar start, Calendar end) { int duration = 0; if (start.after(end)) { logger.error("can not determine duration of training data. start date is after end date."); return duration; } // check years (leap years are ignored) duration += (end.get(Calendar.YEAR) - start.get(Calendar.YEAR)) * 365; // check days duration += end.get(Calendar.DAY_OF_YEAR) - start.get(Calendar.DAY_OF_YEAR) + 1; return duration; }
From source file:com.sammyun.util.DateUtil.java
/** * /* w ww. j a va 2 s . c o m*/ * * @param year String * @return day int */ public static int getDayFromYear(String year) { SimpleDateFormat format = new SimpleDateFormat(year_format); Date date; int day = 0; try { date = format.parse(year); Calendar calendar = new GregorianCalendar(); calendar.setTime(date); day = calendar.getActualMaximum(Calendar.DAY_OF_YEAR); } catch (ParseException e) { e.printStackTrace(); } return day; }
From source file:Time.java
/** * Create a new day, specifying the year and the day of year. The day is * lenient meaning that illegal day parameters can be specified and results in * a recomputed day with legal month/day values. * // w ww . j a v a2 s .co m * @param year * Year of new day. * @param dayOfYear * 1=January 1, etc. */ public Day(int year, int dayOfYear) { initialize(year, Calendar.JANUARY, 1); calendar_.set(Calendar.DAY_OF_YEAR, dayOfYear); }
From source file:com.adsapient.shared.service.FiltersService.java
public static int getClicksForCampainInDay(Integer campainId, boolean increaseCache, boolean isImpression) { StringBuffer stringBuffer = new StringBuffer(); Calendar beginDate = Calendar.getInstance(); int campainImpressionsLocal = 0; String key = new StringBuffer("campain").append(campainId).append("day") .append(beginDate.get(Calendar.DAY_OF_YEAR)).toString(); if (campainClicks.containsKey(key)) { campainImpressionsLocal = ((Integer) campainClicks.get(key)).intValue(); } else {/*from w w w. ja v a 2 s .c o m*/ beginDate.add(Calendar.DAY_OF_YEAR, -1); Collection parametersCollection = new ArrayList(); campainClicks.put(key, new Integer(campainImpressionsLocal)); } if (increaseCache && !isImpression) { campainImpressionsLocal++; campainClicks.put(key, new Integer(campainImpressionsLocal)); } return campainImpressionsLocal; }
From source file:com.itude.mobile.mobbl.core.util.StringUtilities.java
public static String formatDateDependingOnCurrentDate(String dateString) { if (isEmpty(dateString)) { return ""; }/*w w w . j a v a2 s.co m*/ String result = dateString; Date date = dateFromXML(dateString); DateFormat df; // We can't just compare two dates, because the time is also compared. // Therefore the time is removed and the two dates without time are compared Calendar calendar = Calendar.getInstance(); calendar.setTime(date); Calendar today = Calendar.getInstance(); today.setTime(new Date()); if (calendar.get(Calendar.YEAR) == today.get(Calendar.YEAR) && calendar.get(Calendar.MONTH) == today.get(Calendar.MONTH) && calendar.get(Calendar.DAY_OF_YEAR) == today.get(Calendar.DAY_OF_YEAR)) { df = new SimpleDateFormat("HH:mm:ss"); } else { df = DateFormat.getDateInstance(DateFormat.SHORT, getDefaultFormattingLocale() != null ? getDefaultFormattingLocale() : Locale.getDefault()); } // Format the date try { result = df.format(date); return result; } catch (Exception e) { throw new MBDateParsingException( "Could not get format date depending on current date with input string: " + dateString, e); } }