Example usage for java.util Calendar MINUTE

List of usage examples for java.util Calendar MINUTE

Introduction

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

Prototype

int MINUTE

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

Click Source Link

Document

Field number for get and set indicating the minute within the hour.

Usage

From source file:com.square.core.agent.desactivation.relation.DesactivationRelationsAgentJmxThead.java

@Override
public void run() {
    agent.setEtat("Agent DesactivationRelations debut de traitement");
    try {/*from w w w. j a va2  s  .  c o  m*/
        final Calendar date = Calendar.getInstance();
        if (StringUtils.isNotBlank(agent.getDate())) {
            final SimpleDateFormat formatDate = new SimpleDateFormat("dd/MM/yyyy");
            date.setTime(formatDate.parse(agent.getDate()));
        }
        date.clear(Calendar.HOUR);
        date.clear(Calendar.MINUTE);
        date.clear(Calendar.SECOND);
        date.clear(Calendar.MILLISECOND);

        final SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        agent.setEtat("Lancement desactivation relations  la date du " + format.format(date.getTime()));
        int counter = 0;

        // Cration des criteres des relations  dsactiver
        final RelationCriteresRechercheDto criterias = new RelationCriteresRechercheDto();
        criterias.setDateFinMax(date);
        criterias.setActif(true);
        criterias.setSupprime(null);

        // Calcul du nombre total
        final int nbTotal = personneService.countRelationsParCriteres(criterias);
        agent.setEtat("Traitement des relations : " + nbTotal + " lments");
        // Recuparation des ids de relations
        List<Long> listeRelationsADesactiver = personneService.rechercherIdsRelationsADesactiver(date,
                agent.getPagination());

        while (listeRelationsADesactiver.size() > 0 && !agent.isStopping()) {
            counter += listeRelationsADesactiver.size();
            logger.debug("Dsactivation des relations en cours " + counter + " / " + nbTotal);
            personneService.desactiverRelations(listeRelationsADesactiver);

            // Rcupration des relations  dsactiver
            listeRelationsADesactiver = personneService.rechercherIdsRelationsADesactiver(date,
                    agent.getPagination());
        }
    } catch (Exception e) {
        agent.setEtat(e.getMessage());
        e.printStackTrace();
    } finally {
        agent.getSessionFactory().openSession().close();
        agent.stop();
    }
}

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

public void persist(final TickVO event, final Map<?, ?> map) throws IOException {

    Tick tick = Tick.Factory.newInstance();

    tick.setSecurity(this.lookupService.getSecurity(event.getSecurityId()));
    tick.setFeedType(event.getFeedType());
    tick.setLast(event.getLast());//from w  w w .j  a  v a 2s. c om
    tick.setLastDateTime(event.getLastDateTime());
    tick.setVol(event.getVol());
    tick.setAsk(event.getAsk());
    tick.setVolAsk(event.getVolAsk());
    tick.setBid(event.getBid());
    tick.setVolBid(event.getVolBid());

    // get the current Date rounded to MINUTES
    Date date = DateUtils.round(serverEngine.getCurrentTime(), Calendar.MINUTE);
    tick.setDateTime(date);

    this.marketDataPersistenceService.persistTick(tick);
}

From source file:com.qpark.eip.core.spring.statistics.dao.StatisticsLoggingDao.java

/**
 * Get a {@link Date}, where hours, minutes, seconds and milliseconds are
 * set to 0.//from   ww w.  j a  v a 2 s . co m
 *
 * @return the {@link Date} .
 */
private static Date getDayStart(final Date d) {
    final Calendar gc = new GregorianCalendar(LOGGING_TIMEZONE);
    gc.setTime(d);
    gc.set(Calendar.HOUR_OF_DAY, 0);
    gc.set(Calendar.MINUTE, 0);
    gc.set(Calendar.SECOND, 0);
    gc.set(Calendar.MILLISECOND, 0);
    return gc.getTime();
}

From source file:com.adobe.acs.commons.http.headers.impl.AbstractExpiresHeaderFilter.java

@Override
protected String getHeaderValue() {
    Calendar next = Calendar.getInstance();
    next.set(Calendar.HOUR_OF_DAY, expiresTime.get(Calendar.HOUR_OF_DAY));
    next.set(Calendar.MINUTE, expiresTime.get(Calendar.MINUTE));
    next.set(Calendar.SECOND, 0);

    adjustExpires(next);/*w w  w.j  ava2 s  .  c o  m*/

    SimpleDateFormat dateFormat = new SimpleDateFormat(EXPIRES_FORMAT);
    dateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
    return dateFormat.format(next.getTime());
}

From source file:com.ar.dev.tierra.api.dao.impl.MetodoPagoFacturaDAOImpl.java

@Override
public List<MetodoPagoFactura> getDay() {
    Criteria criteria = getSession().createCriteria(MetodoPagoFactura.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.asc("idMetodoPagoFactura"));
    List<MetodoPagoFactura> list = criteria.list();
    return list;//from  w  ww . j a  va2s.  co  m
}

From source file:com.ar.dev.tierra.api.dao.impl.DetalleFacturaDAOImpl.java

@Override
public List<DetalleFactura> getDay() {
    Criteria criteria = getSession().createCriteria(DetalleFactura.class);
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.HOUR_OF_DAY, 0);
    calendar.set(Calendar.MINUTE, 0);
    calendar.set(Calendar.SECOND, 0);
    Date fromDate = calendar.getTime();
    calendar.set(Calendar.HOUR_OF_DAY, 23);
    calendar.set(Calendar.MINUTE, 59);
    calendar.set(Calendar.SECOND, 59);
    Date toDate = calendar.getTime();
    criteria.add(Restrictions.between("fechaCreacion", fromDate, toDate));
    criteria.addOrder(Order.asc("idDetalleFactura"));
    List<DetalleFactura> list = criteria.list();
    return list;/*from   w  w  w .ja v a 2s .  c  o  m*/
}

From source file:com.silverpeas.calendar.DateTime.java

/**
 * Creates a new date time from the specified parts of the time specification year month day hour
 * minute second millisecond. The hour, minute, second and millisecond parts are optional; if not
 * passed, they are set at 0. For example, the following patterns are valid:
 * <ul>//from  w  w w .j a v a 2 s .  co  m
 * <li>at(2011, 5, 23, 10, 57, 23, 12) meaning in ISO 86601 2011-05-23T10:57:23.012</li>
 * <li>at(2011, 5, 23, 10, 57, 23) meaning in ISO 86601 2011-05-23T10:57:23.00</li>
 * <li>at(2011, 5, 23, 10, 57) meaning in ISO 86601 2011-05-23T10:57:00.00</li>
 * <li>at(2011, 5, 23, 10) meaning in ISO 86601 2011-05-23T10:00:00.00</li>
 * <li>at(2011, 5, 23) meaning in ISO 86601 2011-05-23T00:00:00.00</li>
 * </ul>
 * @param timeParts the different parts of the date time to set in the following order: year,
 * month, day, hour, minute, second, millisecond. The year, month, and day are mandatory whereas
 * other time parts are optional. If one optional part isn't passed, then it is set to 0.
 * @return a date time matching the specified date and time specification.
 */
public static DateTime dateTimeAt(int... timeParts) {
    if (timeParts.length < 3) {
        throw new IllegalArgumentException("The year, month and day must be set");
    }
    Calendar calendar = Calendar.getInstance();
    calendar.set(timeParts[0], timeParts[1], timeParts[2], 0, 0, 0);
    calendar.set(Calendar.MILLISECOND, 0);
    if (timeParts.length >= 4) {
        calendar.set(Calendar.HOUR_OF_DAY, timeParts[3]);
        if (timeParts.length >= 5) {
            calendar.set(Calendar.MINUTE, timeParts[4]);
            if (timeParts.length >= 6) {
                calendar.set(Calendar.SECOND, timeParts[5]);
                if (timeParts.length >= 7) {
                    calendar.set(Calendar.MILLISECOND, timeParts[6]);
                }
            }
        }
    }
    return new DateTime(calendar.getTime());
}

From source file:net.seratch.taskun.util.CalendarUtil.java

 public static Calendar getCalendar(int yyyy, int mm, int dd, int hh,
      int mi, int ss) {
   Calendar cal = getCalendar(yyyy, mm, dd);
   cal.set(Calendar.HOUR_OF_DAY, hh);
   cal.set(Calendar.MINUTE, mi);
   cal.set(Calendar.SECOND, ss);/*  w w  w.j  a  v a  2  s.  c  om*/
   return cal;
}

From source file:Main.java

/**
 *
 * This method is a utility method to create a new java.sql.Date in one line.
 *
 * @param year//  w w  w  . ja v  a 2 s .c om
 * @param month
 * @param day
 * @param hour
 * @param minute
 * @param second
 *
 * @return a populated java.sql.Date with the year, month, hour, minute, and second populated, with no value for millisecond.
 *
 */
public static java.sql.Date newDate(Integer year, Integer month, Integer day, Integer hour, Integer minute,
        Integer second) {

    // test for null arguments
    if (year == null) {
        throw new IllegalArgumentException("Argument 'year' passed in was null.");
    }
    if (month == null) {
        throw new IllegalArgumentException("Argument 'month' passed in was null.");
    }
    if (day == null) {
        throw new IllegalArgumentException("Argument 'day' passed in was null.");
    }
    if (hour == null) {
        throw new IllegalArgumentException("Argument 'hour' passed in was null.");
    }
    if (minute == null) {
        throw new IllegalArgumentException("Argument 'minute' passed in was null.");
    }
    if (second == null) {
        throw new IllegalArgumentException("Argument 'second' passed in was null.");
    }

    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, year);
    calendar.set(Calendar.MONTH, month);
    calendar.set(Calendar.DAY_OF_MONTH, day);
    calendar.set(Calendar.HOUR_OF_DAY, hour);
    calendar.set(Calendar.MINUTE, minute);
    calendar.set(Calendar.SECOND, second);
    calendar.clear(Calendar.MILLISECOND);

    return new java.sql.Date(calendar.getTimeInMillis());
}

From source file:net.sf.l2j.gameserver.model.entity.ClanHallSiege.java

public void setNewSiegeDate(long siegeDate, int ClanHallId, int hour) {
    Calendar tmpDate = Calendar.getInstance();
    if (siegeDate <= System.currentTimeMillis()) {
        tmpDate.setTimeInMillis(System.currentTimeMillis());
        tmpDate.add(Calendar.DAY_OF_MONTH, 3);
        tmpDate.set(Calendar.DAY_OF_WEEK, 6);
        tmpDate.set(Calendar.HOUR_OF_DAY, hour);
        tmpDate.set(Calendar.MINUTE, 0);
        tmpDate.set(Calendar.SECOND, 0);
        setSiegeDate(tmpDate);// w  w w.j a  v a  2 s.  c  o  m
        Connection con = null;
        try {
            con = L2DatabaseFactory.getInstance().getConnection();
            PreparedStatement statement = con
                    .prepareStatement("UPDATE clanhall_siege SET siege_data=? WHERE id = ?");
            statement.setLong(1, getSiegeDate().getTimeInMillis());
            statement.setInt(2, ClanHallId);
            statement.execute();
            statement.close();
        } catch (Exception e) {
            _log.error("Exception: can't save clanhall siege date: " + e.getMessage(), e);
        } finally {
            try {
                if (con != null)
                    con.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }
    }
}