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:de.micromata.genome.util.types.DateUtils.java
/** * Die Anzahl Arbeitstage (d.h. nicht Samstag und Sonntag) addieren. * * @param date Nie <code>null</code> * @param workdayOffset Offset in Tagen (1=morgen) * @return Nie <code>null</code> (Tagesdatum ohne *//*from ww w.ja v a 2 s . c om*/ public static Date addWorkdays(Date date, int workdayOffset) { final Calendar cal = getCalendarInstance(); cal.setTime(date); ensureWorkday(cal); for (int countdown = workdayOffset; countdown > 0; countdown--) { cal.add(Calendar.DAY_OF_YEAR, 1); ensureWorkday(cal); } final Date result = cal.getTime(); return result; }
From source file:com.algomedica.service.LicenseManagerServiceImpl.java
/** * @param oldExpiryDate/*from w w w. j ava 2 s.c o m*/ * @param lsExipryDays * @return * @throws ParseException */ private Date calculateExpiryDate(long lsExipryDays) throws ParseException { Calendar c = Calendar.getInstance(); // starts with today's date and c.add(Calendar.DAY_OF_YEAR, Integer.valueOf(String.valueOf(lsExipryDays))); DateFormat outputFormatter = new SimpleDateFormat("MM/dd/yyyy"); Date date = c.getTime(); date = outputFormatter.parse(outputFormatter.format(date.getTime())); return date; }
From source file:es.ficonlan.web.backend.test.eventservice.EventServiceTest.java
@Test public void testChangeActivityData() throws ServiceException { Session anonymousSession = userService.newAnonymousSession(); Session s = userService.login(anonymousSession.getSessionId(), ADMIN_LOGIN, ADMIN_PASS); Calendar dateStart = Calendar.getInstance(); Calendar dateEnd = Calendar.getInstance(); dateEnd.add(Calendar.DAY_OF_YEAR, 1); Event event = new Event(0, "FicOnLan 2014", "FicOnLan 2014", 150, dateStart, dateEnd, dateStart, dateEnd, null, null, null, null, null); eventDao.save(event);// w w w . j av a 2 s . c o m Activity activity = eventService.addActivity(s.getSessionId(), event.getEventId(), new Activity(event, "Torneo de Lol", "Torneo de Lol", 10, ActivityType.Tournament, true, dateStart, dateEnd, dateStart, dateEnd)); dateStart.add(Calendar.HOUR, 1); dateEnd.add(Calendar.HOUR, 2); eventService.changeActivityData(s.getSessionId(), activity.getActivityId(), new Activity(activity.getActivityId(), "Concurso de hacking", "Concurso de hacking", 20, ActivityType.Production, false, dateStart, dateEnd, dateStart, dateEnd)); assertTrue(activity.getName().contentEquals("Concurso de hacking")); assertTrue(activity.getDescription().contentEquals("Concurso de hacking")); assertTrue(activity.getNumParticipants() == 20); assertTrue(activity.getType() == ActivityType.Production); assertTrue(!activity.isOficial()); assertTrue(activity.getStartDate().compareTo(dateStart) == 0); assertTrue(activity.getEndDate().compareTo(dateEnd) == 0); assertTrue(activity.getRegDateOpen().compareTo(dateStart) == 0); assertTrue(activity.getRegDateClose().compareTo(dateEnd) == 0); }
From source file:com.oasis.wolfburg.service.truckRSSchedule.TruckRSJobComponent.java
/** * /*from w ww. j a va 2 s . co m*/ * ?? */ private void setDefaultOrder(List<TRSJobOrder> orderList) { /** * */ boolean todayOrder = false; for (TRSJobOrder jobOrder : orderList) { Calendar cal = Calendar.getInstance(); Calendar cal1 = Calendar.getInstance(); cal1.setTime(jobOrder.getStartDate()); if (cal.get(Calendar.DAY_OF_YEAR) == cal1.get(Calendar.DAY_OF_YEAR)) { jobOrder.setDefaultOrder(true); todayOrder = true; return; } } /** * 'DISPATCHED' */ boolean dispatchedOrder = false; if (!todayOrder) { for (TRSJobOrder jobOrder : orderList) { if (RSJobStatus.DISPATCHED == jobOrder.getStatus()) { jobOrder.setDefaultOrder(true); dispatchedOrder = true; return; } } } /** * PLANED */ boolean planOrder = false; if (!dispatchedOrder) { for (TRSJobOrder jobOrder : orderList) { if (RSJobStatus.PLANED == jobOrder.getStatus()) { jobOrder.setDefaultOrder(true); planOrder = true; return; } } } /** * 'ENROUTE' */ boolean enrouteOrder = false; if (!planOrder) { for (TRSJobOrder jobOrder : orderList) { if (RSJobStatus.ENROUTE == jobOrder.getStatus()) { jobOrder.setDefaultOrder(true); enrouteOrder = true; return; } } } /** * ? */ if (!enrouteOrder) { orderList.get(0).setDefaultOrder(true); } }
From source file:com.redhat.rhn.frontend.action.monitoring.notification.BaseFilterEditAction.java
private List makeFrequencyTypes() { ArrayList result = new ArrayList(); result.add(lv("filter-form.jspf.daily", new Long(Calendar.DAY_OF_YEAR).toString())); result.add(lv("filter-form.jspf.weekly", new Long(Calendar.WEEK_OF_YEAR).toString())); result.add(lv("filter-form.jspf.monthly", new Long(Calendar.MONTH).toString())); localize(result);/*from w w w. j a va2 s . c om*/ return result; }
From source file:nz.co.senanque.rules.OperationsImpl.java
@InternalFunction() public Number daysSince(Date value) { if (value == null) { return 0.0; }/* ww w. ja v a2 s .c o m*/ Calendar today = getToday(); Calendar c = getCalendar(value); int thisYear = today.get(Calendar.YEAR); int thisDayOfYear = today.get(Calendar.DAY_OF_YEAR); int ret = ((thisYear - c.get(Calendar.YEAR)) * 365) + (thisDayOfYear - c.get(Calendar.DAY_OF_YEAR)); return new Double(ret); }
From source file:org.jrecruiter.service.impl.JobServiceImpl.java
/** {@inheritDoc} */ @Override//from ww w. j a v a 2 s .c om public void updateJobCountPerDays(final Calendar asOfDay) { final Calendar today = CalendarUtils.getCalendarWithoutTime(); today.setTime(asOfDay.getTime()); final Calendar yesterday = CalendarUtils.getCalendarWithoutTime(); yesterday.add(Calendar.DAY_OF_YEAR, -1); final List<JobCountPerDay> latestTwoJobCountPerDays = jobCountPerDayDao.getLatestTwoJobCounts(); //If nothing exists yet, create an entry with zero jobs. if (latestTwoJobCountPerDays.isEmpty()) { jobCountPerDayDao.save(new JobCountPerDay(yesterday.getTime(), 0L, 0L, 0L)); } boolean containsToday = false; //Let's make sure we have a value for today for (JobCountPerDay jobCountPerDay : latestTwoJobCountPerDays) { if (today.getTime().equals(jobCountPerDay.getJobDate())) { containsToday = true; break; } } if (!containsToday) { //We need to create a value for today final Long totalNumberOfJobs = this.getJobsCount(); jobCountPerDayDao.save(new JobCountPerDay(today.getTime(), 0L, 0L, totalNumberOfJobs)); } }
From source file:persistence.OrderDao.java
private Date dayAgo() { Calendar cl = Calendar.getInstance(); cl.add(Calendar.DAY_OF_YEAR, -1); return cl.getTime(); }
From source file:com.persistent.cloudninja.service.impl.ProvisioningServiceImpl.java
/** * Assigns relying party key and addresses to the relying party. * /*from www. j a va 2s.co m*/ * @param relyingParty * @param tenantId * @throws Exception */ private void assignRelyingPartyKeyAndAddresses(RelyingParty relyingParty, String tenantId) throws Exception { //create relying party key RelyingPartyKey relyingPartyKey = new RelyingPartyKey(); relyingPartyKey.setDisplayName("RPKey" + tenantId); relyingPartyKey.setType("X509Certificate"); relyingPartyKey.setUsage("Signing"); relyingPartyKey.setValue(getCertificateBytes(tenantId)); relyingPartyKey.setRelyingPartyId(relyingParty.getId()); //set start time Calendar calendar = Calendar.getInstance(); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S z"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); String startDate = dateFormat.format(calendar.getTime()); relyingPartyKey.setStartDate(dateFormat.parse(startDate)); //set end time //The certificate is valid for 1 year. calendar.add(Calendar.DAY_OF_YEAR, 364); String endDate = dateFormat.format(calendar.getTime()); relyingPartyKey.setEndDate(dateFormat.parse(endDate)); relyingPartyKey.setPassword(String.format(passwordPrefix, tenantId).getBytes()); relyingPartyKey.setIsPrimary(true); managementService.addEntity(relyingPartyKey); assignRealm(relyingParty, tenantId); assignReturnURL(relyingParty, tenantId); }