Example usage for java.util Calendar DAY_OF_YEAR

List of usage examples for java.util Calendar DAY_OF_YEAR

Introduction

In this page you can find the example usage for java.util Calendar DAY_OF_YEAR.

Prototype

int DAY_OF_YEAR

To view the source code for java.util Calendar DAY_OF_YEAR.

Click Source Link

Document

Field number for get and set indicating the day number within the current year.

Usage

From source file:com.hangum.tadpole.manager.core.editor.executedsql.SQLAuditEditor.java

/**
 * ??  .//from  w  w w.  j a v a 2 s. co  m
 */
private void initUIData() {

    try {
        if (roleType == USER_ROLE_TYPE.SYSTEM_ADMIN) {
            listUserDBDAO = TadpoleSystem_UserDBQuery.getUserDB(userDAO);
        } else {
            userDAO = new UserDAO();
            userDAO.setSeq(SessionManager.getUserSeq());
            listUserDBDAO = TadpoleSystem_UserDBQuery.getUserDB(userDAO);
        }

        comboDatabase.add("All"); //$NON-NLS-1$
        comboDatabase.setData("All", null); //$NON-NLS-1$

        for (UserDBDAO userDBDAO : listUserDBDAO) {
            comboDatabase.add(userDBDAO.getDisplay_name());
            comboDatabase.setData(userDBDAO.getDisplay_name(), userDBDAO);
        }
        comboDatabase.setVisibleItemCount(listUserDBDAO.size() + 1);
        comboDatabase.select(0);

    } catch (Exception e) {
        logger.error("get db list", e); //$NON-NLS-1$
    }
    // Range of date
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_YEAR, -1);
    dateTimeStart.setDate(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));

    callbackui();
}

From source file:com.alkacon.opencms.calendar.CmsCalendarDisplay.java

/** 
 * Returns the calendar entries of the collected resources that match the actual
 * time period.<p>/*from w  w  w  . j ava 2  s.c om*/
 * 
 * @param type the type of time period
 * @return all entries for the days of the specified range with their corresponding entries as lists
 */
public Map getEntriesForCurrentPeriod(int type) {

    Calendar current = getCurrentDate();
    switch (type) {
    case PERIOD_DAY:
        return getEntriesForDay(current.get(Calendar.YEAR), current.get(Calendar.DAY_OF_YEAR));
    case PERIOD_WEEK:
        return getEntriesForWeek(current.get(Calendar.YEAR), current.get(Calendar.WEEK_OF_YEAR));
    case PERIOD_MONTH:
        return getEntriesForMonth(current.get(Calendar.YEAR), current.get(Calendar.MONTH));
    case PERIOD_YEAR:
        return getEntriesForYear(current.get(Calendar.YEAR));
    default:
        return new TreeMap();
    }
}

From source file:com.ecarinfo.weichexin.httpserver.module.CarManager.java

private List<ECCarInfoItemVO> weekList(List<ECCarInfoItemVO> list) {
    Calendar nowDate = Calendar.getInstance();
    Calendar canlendar = Calendar.getInstance();
    List<ECCarInfoItemVO> voList = new ArrayList<ECCarInfoItemVO>();
    try {/*from www . j  a v a2  s . c o m*/

        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");

        nowDate.setTime(format.parse(format.format(new Date())));
        nowDate.add(Calendar.WEEK_OF_YEAR, -1);
        String s = format.format(nowDate.getTime());
        //?1
        nowDate.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);//
        int lastday = nowDate.get(Calendar.DAY_OF_MONTH);//
        nowDate.add(Calendar.DAY_OF_YEAR, -1);
        if (list != null && list.size() > 0) {
            for (int i = 0; i < 7; i++) {
                boolean flag = true;
                nowDate.add(Calendar.DAY_OF_YEAR, 1);
                for (int k = 0; k < list.size(); k++) {
                    if (list.get(k).getFromDay() != null) {
                        canlendar.setTime(list.get(k).getFromDay());
                        if (nowDate.getTimeInMillis() == canlendar.getTimeInMillis()) {//?vo??
                            voList.add(list.get(k));
                            flag = false;
                            break;
                        }
                    }
                }
                if (flag) {
                    ECCarInfoItemVO vo = new ECCarInfoItemVO();
                    vo.setFromDay(format.parse(format.format(nowDate.getTime())));
                    vo.setTotalOil(0f);
                    vo.setTotalMileage(0f);
                    voList.add(vo);
                    BeanUtils.toString(vo);
                }

            }
        } else {//?0
            for (int i = 1; i <= 7; i++) {
                nowDate.add(Calendar.DAY_OF_YEAR, 1);
                format.format(nowDate.getTime());
                ECCarInfoItemVO vo = new ECCarInfoItemVO();
                vo.setFromDay(format.parse(format.format(nowDate.getTime())));
                vo.setTotalOil(0f);
                vo.setTotalMileage(0f);
                voList.add(vo);
                BeanUtils.toString(vo);
            }
        }
    } catch (Exception e) {
        logger.error("??", e);

    }
    return voList;
}

From source file:com.commander4j.util.JUtility.java

/**
 * Method getJulianDay./*from w ww  .  j  a v a 2 s  . co  m*/
 * 
 * @param currentDate
 *            Calendar
 * @return long
 */
public static long getJulianDay(Calendar currentDate) {
    long result = 0;

    result = currentDate.get(Calendar.DAY_OF_YEAR);

    return result;
}

From source file:es.ficonlan.web.backend.test.eventservice.EventServiceTest.java

@Test
public void getRegistrationTest() throws ServiceException {
    Session anonymousSession = userService.newAnonymousSession();
    Session s = userService.login(anonymousSession.getSessionId(), ADMIN_LOGIN, ADMIN_PASS);
    Calendar regCloseDate = Calendar.getInstance();
    regCloseDate.add(Calendar.DAY_OF_YEAR, 1);
    Calendar dateStart = Calendar.getInstance();
    dateStart.add(Calendar.DAY_OF_YEAR, -1);
    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  ww  .  ja  v a 2  s. co m*/
    User user = userService.addUser(anonymousSession.getSessionId(),
            new User("User1", "login1", "pass", "12345678R", "user1@gmail.com", "690047407", "L"));
    Registration r1 = eventService.addParticipantToEvent(s.getSessionId(), user.getUserId(),
            event.getEventId());
    Registration r2 = eventService.getRegistration(s.getSessionId(), user.getUserId(), event.getEventId());
    assertEquals(r1, r2);

}

From source file:com.alkacon.opencms.calendar.CmsCalendarDisplay.java

/**
 * Returns the list of calendar entries as {@link CmsCalendarEntry} objects for the specified day.<p>
 * //from  ww w  . j a v  a 2  s. c  om
 * @param year the year of the day to display
 * @param day the day of the year to get the entries for
 * @return the list of calendar entries for the specified day
 */
public Map getEntriesForDay(int year, int day) {

    Calendar startDay = new GregorianCalendar(getJsp().getRequestContext().getLocale());
    startDay.set(Calendar.YEAR, year);
    startDay.set(Calendar.DAY_OF_YEAR, day);

    Calendar endDay = (Calendar) startDay.clone();
    return getEntriesForDays(startDay, endDay);
}

From source file:it.govpay.web.rs.dars.monitoraggio.pagamenti.PagamentiHandler.java

@Override
public Dettaglio getDettaglio(long id, UriInfo uriInfo, BasicBD bd)
        throws WebApplicationException, ConsoleException {
    String methodName = "dettaglio " + this.titoloServizio + "." + id;

    try {//from   w w w.j a v  a 2 s .  c om
        this.log.info("Esecuzione " + methodName + " in corso...");
        // Operazione consentita solo ai ruoli con diritto di lettura
        this.darsService.checkDirittiServizioLettura(bd, this.funzionalita);

        Set<Long> setDomini = this.darsService.getIdDominiAbilitatiLetturaServizio(bd, this.funzionalita);
        boolean eseguiRicerca = !setDomini.isEmpty();

        PagamentiBD pagamentiBD = new PagamentiBD(bd);

        if (eseguiRicerca && !setDomini.contains(-1L)) {
            List<Long> idDomini = new ArrayList<Long>();
            PagamentoFilter filter = pagamentiBD.newFilter();
            List<Long> lstCodDomini = new ArrayList<Long>();
            lstCodDomini.addAll(setDomini);
            idDomini.addAll(setDomini);
            filter.setIdDomini(toListCodDomini(idDomini, bd));
            List<Long> idPagamentiL = new ArrayList<Long>();
            idPagamentiL.add(id);
            filter.setIdPagamenti(idPagamentiL);

            long count = eseguiRicerca ? pagamentiBD.count(filter) : 0;
            eseguiRicerca = eseguiRicerca && count > 0;
        }

        Pagamento pagamento = eseguiRicerca ? pagamentiBD.getPagamento(id) : null;

        InfoForm infoModifica = null;
        InfoForm infoCancellazione = pagamento != null
                ? this.getInfoCancellazioneDettaglio(uriInfo, bd, pagamento)
                : null;
        InfoForm infoEsportazione = pagamento != null
                ? this.getInfoEsportazioneDettaglio(uriInfo, bd, pagamento)
                : null;

        String titolo = Utils.getInstance(this.getLanguage())
                .getMessageFromResourceBundle(this.nomeServizio + ".dettaglio.label.titolo");
        Dettaglio dettaglio = new Dettaglio(titolo, infoEsportazione, infoCancellazione, infoModifica);

        if (pagamento != null) {
            // Sezione root coi dati del pagamento
            it.govpay.web.rs.dars.model.Sezione sezioneRoot = dettaglio.getSezioneRoot();

            Date dataPagamento = pagamento.getDataPagamento();
            Stato stato = pagamento.getStato();

            String statoPagamento = Utils.getInstance(this.getLanguage())
                    .getMessageFromResourceBundle(this.nomeServizio + ".stato." + Stato.INCASSATO.name());

            if (!stato.equals(Stato.INCASSATO)) {
                boolean inRitardo = false;
                Integer sogliaGiorniRitardoPagamenti = ConsoleProperties.getInstance()
                        .getSogliaGiorniRitardoPagamenti();
                if (sogliaGiorniRitardoPagamenti != null && sogliaGiorniRitardoPagamenti.intValue() > 0) {
                    Calendar c = Calendar.getInstance();
                    c.setTime(new Date());
                    c.add(Calendar.DAY_OF_YEAR, -sogliaGiorniRitardoPagamenti.intValue());
                    inRitardo = dataPagamento.getTime() < c.getTime().getTime();
                }

                if (inRitardo) {
                    statoPagamento = Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                            this.nomeServizio + ".stato." + PagamentoFilter.STATO_RITARDO_INCASSO);
                } else {
                    statoPagamento = Utils.getInstance(this.getLanguage())
                            .getMessageFromResourceBundle(this.nomeServizio + ".stato." + Stato.PAGATO.name());
                }
            }

            sezioneRoot.addVoce(Utils.getInstance(this.getLanguage())
                    .getMessageFromResourceBundle(this.nomeServizio + ".stato.label"), statoPagamento);

            if (StringUtils.isNotEmpty(pagamento.getCodDominio())) {
                try {
                    Dominio dominio = pagamento.getDominio(bd);
                    Domini dominiDars = new Domini();
                    Elemento elemento = ((DominiHandler) dominiDars.getDarsHandler()).getElemento(dominio,
                            dominio.getId(), dominiDars.getPathServizio(), bd);
                    sezioneRoot.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                            this.nomeServizio + ".idDominio.label"), elemento.getTitolo());
                } catch (Exception e) {
                    sezioneRoot.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                            this.nomeServizio + ".idDominio.label"), pagamento.getCodDominio());
                }
            }

            if (StringUtils.isNotEmpty(pagamento.getIuv()))
                sezioneRoot.addVoce(Utils.getInstance(this.getLanguage())
                        .getMessageFromResourceBundle(this.nomeServizio + ".iuv.label"), pagamento.getIuv());
            if (StringUtils.isNotEmpty(pagamento.getIur()))
                sezioneRoot.addVoce(Utils.getInstance(this.getLanguage())
                        .getMessageFromResourceBundle(this.nomeServizio + ".iur.label"), pagamento.getIur());

            SingoloVersamento singoloVersamento = pagamento.getSingoloVersamento(bd);

            if (singoloVersamento != null) {
                sezioneRoot.addVoce(
                        Utils.getInstance(this.getLanguage())
                                .getMessageFromResourceBundle(this.nomeServizio + ".importoDovuto.label"),
                        singoloVersamento.getImportoSingoloVersamento().toString() + "");
            }

            if (pagamento.getImportoPagato() != null)
                sezioneRoot.addVoce(
                        Utils.getInstance(this.getLanguage())
                                .getMessageFromResourceBundle(this.nomeServizio + ".importoPagato.label"),
                        (pagamento.getImportoPagato().toString() + ""));

            if (pagamento.getCommissioniPsp() != null)
                sezioneRoot.addVoce(
                        Utils.getInstance(this.getLanguage())
                                .getMessageFromResourceBundle(this.nomeServizio + ".commissioniPsp.label"),
                        (pagamento.getCommissioniPsp().toString() + ""));

            if (StringUtils.isNotEmpty(pagamento.getIbanAccredito()))
                sezioneRoot.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                        this.nomeServizio + ".ibanAccredito.label"), pagamento.getIbanAccredito());

            if (dataPagamento != null)
                sezioneRoot.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                        this.nomeServizio + ".dataPagamento.label"), this.sdf.format(dataPagamento));

            //         TipoAllegato tipoAllegato = pagamento.getTipoAllegato();
            //         if(tipoAllegato!= null)
            //            sezioneRoot.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(this.nomeServizio + ".tipoAllegato.label"),
            //                  Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(this.nomeServizio + ".tipoAllegato."+tipoAllegato.name()));

            if (singoloVersamento != null) {
                Versamento versamento = singoloVersamento.getVersamento(pagamentiBD);
                Versamenti versamentiDars = new Versamenti();
                VersamentiHandler versamentiDarsHandler = (VersamentiHandler) versamentiDars.getDarsHandler();
                Elemento elemento = versamentiDarsHandler.getElemento(versamento, versamento.getId(),
                        versamentiDars.getPathServizio(), bd);
                sezioneRoot.addVoce(
                        Utils.getInstance(this.getLanguage())
                                .getMessageFromResourceBundle(this.nomeServizio + ".idVersamento.label"),
                        Utils.getInstance(this.getLanguage())
                                .getMessageFromResourceBundle("commons.label.visualizza"),
                        elemento.getUri());

                sezioneRoot.addVoce(
                        Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                                this.nomeServizio + ".codSingoloVersamentoEnte.label"),
                        singoloVersamento.getCodSingoloVersamentoEnte());
            }

            Rpt rpt = pagamento.getRpt(bd);
            if (rpt != null) {
                Transazioni transazioniDars = new Transazioni();
                TransazioniHandler transazioniDarsHandler = (TransazioniHandler) transazioniDars
                        .getDarsHandler();
                Elemento elemento = transazioniDarsHandler.getElemento(rpt, rpt.getId(),
                        transazioniDars.getPathServizio(), bd);
                sezioneRoot.addVoce(
                        Utils.getInstance(this.getLanguage())
                                .getMessageFromResourceBundle(this.nomeServizio + ".rpt.label"),
                        Utils.getInstance(this.getLanguage())
                                .getMessageFromResourceBundle("commons.label.visualizza"),
                        elemento.getUri());
            }

            if (pagamento.getIdRr() != null) {
                String etichettaRevoca = Utils.getInstance(this.getLanguage())
                        .getMessageFromResourceBundle(this.nomeServizio + ".sezioneRevoca.titolo");
                it.govpay.web.rs.dars.model.Sezione sezioneRevoca = dettaglio.addSezione(etichettaRevoca);

                if (pagamento.getDataAcquisizioneRevoca() != null)
                    sezioneRoot.addVoce(
                            Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                                    this.nomeServizio + ".dataAcquisizioneRevoca.label"),
                            this.sdf.format(pagamento.getDataAcquisizioneRevoca()));

                if (StringUtils.isNotEmpty(pagamento.getCausaleRevoca()))
                    sezioneRevoca.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                            this.nomeServizio + ".causaleRevoca.label"), pagamento.getCausaleRevoca());
                if (StringUtils.isNotEmpty(pagamento.getDatiRevoca()))
                    sezioneRevoca.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                            this.nomeServizio + ".datiRevoca.label"), pagamento.getDatiRevoca());
                if (StringUtils.isNotEmpty(pagamento.getEsitoRevoca()))
                    sezioneRevoca.addVoce(Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                            this.nomeServizio + ".esitoRevoca.label"), pagamento.getEsitoRevoca());
                if (StringUtils.isNotEmpty(pagamento.getDatiEsitoRevoca()))
                    sezioneRevoca.addVoce(
                            Utils.getInstance(this.getLanguage())
                                    .getMessageFromResourceBundle(this.nomeServizio + ".datiEsitoRevoca.label"),
                            pagamento.getDatiEsitoRevoca());

                if (pagamento.getImportoRevocato() != null)
                    sezioneRevoca.addVoce(
                            Utils.getInstance(this.getLanguage())
                                    .getMessageFromResourceBundle(this.nomeServizio + ".importoRevocato.label"),
                            (pagamento.getImportoRevocato().toString() + ""));

                Rr rr = pagamento.getRr(bd);
                if (rr != null) {
                    Revoche revocheDars = new Revoche();
                    RevocheHandler revocheDarsHandler = (RevocheHandler) revocheDars.getDarsHandler();
                    Elemento elemento = revocheDarsHandler.getElemento(rr, rr.getId(),
                            revocheDars.getPathServizio(), bd);
                    sezioneRevoca.addVoce(
                            Utils.getInstance(this.getLanguage())
                                    .getMessageFromResourceBundle(this.nomeServizio + ".rr.label"),
                            Utils.getInstance(this.getLanguage()).getMessageFromResourceBundle(
                                    "commons.label.visualizza"),
                            elemento.getUri());
                }
            }

        }
        this.log.info("Esecuzione " + methodName + " completata.");

        return dettaglio;
    } catch (WebApplicationException e) {
        throw e;
    } catch (Exception e) {
        throw new ConsoleException(e);
    }
}

From source file:com.alkacon.opencms.calendar.CmsCalendarDisplay.java

/**
 * Returns all entries for the days of the specified range with their corresponding entries as lists.<p>
 * //from   w  ww.  j  a va  2s  . co  m
 * The key of the Map has to be a Date object.<p>
 * 
 * The Map values are always lists of {@link CmsCalendarEntry} objects, if no entries are available for a specific day,
 * an empty List is stored in the Map.<p>
 * 
 * @param startDay the start day of the range
 * @param endDay the end day of the range
 * @return all entries for the days of the specified range with their corresponding entries as lists
 */
public Map getEntriesForDays(Calendar startDay, Calendar endDay) {

    Map displayDays = new TreeMap();
    // first get all entries to display
    Map displayEntries = getDisplayedEntries(startDay, endDay);
    Calendar runDay = setDayTime(startDay, 0, 0, 0);
    while (true) {
        List entries = (List) displayEntries.get(runDay.getTime());
        if (entries == null) {
            entries = new ArrayList(0);
        }
        displayDays.put(runDay.getTime(), entries);

        // increase day to next day
        runDay.add(Calendar.DAY_OF_YEAR, 1);
        if (runDay.after(endDay)) {
            // runDay has reached endDay -> stop loop
            break;
        }
    }
    return displayDays;
}

From source file:com.aurel.track.move.ItemMoveBL.java

public static Date stepBack(Date dateParam, int steps, boolean withCheckingFreeDays) {
    if (dateParam == null) {
        return null;
    }/* ww w  .  j  a v  a2 s .  c o m*/
    int actualSteps = 0;
    Calendar cal = Calendar.getInstance();
    cal.setTime(dateParam);
    Date newDate = new Date();
    while (actualSteps < steps) {
        cal.add(Calendar.DAY_OF_YEAR, -1);
        newDate = cal.getTime();
        if (withCheckingFreeDays) {
            if (!WorkDaysConfigImplementation.isSaturday(newDate)
                    && !WorkDaysConfigImplementation.isSunday(newDate)
                    && !WorkDaysConfigImplementation.isFreeDay(newDate)) {
                actualSteps++;
            }
        } else {
            actualSteps++;
        }
    }
    return newDate;
}

From source file:ch.algotrader.service.PortfolioServiceImpl.java

/**
 * {@inheritDoc}//from   w  w w. j  a va2s . c o m
 */
@Override
public Collection<PortfolioValueVO> getPortfolioValuesInclPerformanceSinceDate(final String strategyName,
        final Date date) {

    Validate.notEmpty(strategyName, "Strategy name is empty");
    Validate.notNull(date, "Date is null");

    Collection<PortfolioValueVO> portfolioValues = this.portfolioValueDao.findByStrategyAndMinDate(strategyName,
            date, PortfolioValueVOProducer.INSTANCE);

    // calculate the performance
    double lastNetLiqValue = 0;
    double lastDayNetLiqValue = 0;
    double performance = 1.0;
    double dailyPerformance = 1.0;
    for (PortfolioValueVO portfolioValue : portfolioValues) {

        // for AlgoTrader Server reset performance at the 24:00 based on NetLiqValue of prior day
        if (StrategyImpl.SERVER.equals(strategyName)
                && DateUtils.getFragmentInHours(portfolioValue.getDateTime(), Calendar.DAY_OF_YEAR) == 0) {
            if (lastDayNetLiqValue != 0) {
                dailyPerformance = dailyPerformance * (portfolioValue.getNetLiqValue().doubleValue()
                        / (lastDayNetLiqValue + (portfolioValue.getCashFlow() != null
                                ? portfolioValue.getCashFlow().doubleValue()
                                : 0)));
                performance = dailyPerformance;
                portfolioValue.setPerformance(performance - 1.0);
            }

            lastDayNetLiqValue = portfolioValue.getNetLiqValue().doubleValue();
            lastNetLiqValue = portfolioValue.getNetLiqValue().doubleValue();

        } else {
            if (lastNetLiqValue != 0) {
                performance = performance * (portfolioValue.getNetLiqValue().doubleValue() / (lastNetLiqValue
                        + (portfolioValue.getCashFlow() != null ? portfolioValue.getCashFlow().doubleValue()
                                : 0)));
                portfolioValue.setPerformance(performance - 1.0);
            }

            lastNetLiqValue = portfolioValue.getNetLiqValue().doubleValue();
        }
    }

    return portfolioValues;

}